/*
 * 湖北祖安 CRM 统一设计系统
 * 规则来源：docs/DESIGN_SYSTEM.md
 * 此文件在旧版 styles.css 之后加载，用作全系统唯一公共视觉层。
 */
:root {
  color-scheme: light;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono-numeric: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --text: #172033;
  --text-secondary: #526277;
  --text-tertiary: #718096;
  --text-disabled: #9aa7b7;
  --surface-page: #f4f7fb;
  --surface-panel: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-muted: #eef3f8;
  --border: #d6e0eb;
  --border-strong: #b9c9da;
  --brand: #145da5;
  --brand-hover: #0f4f8e;
  --brand-active: #0c4278;
  --brand-soft: #eaf3fc;
  --success: #187451;
  --success-soft: #eaf7f0;
  --warning: #a46613;
  --warning-soft: #fff7e5;
  --danger: #b42318;
  --danger-hover: #931c14;
  --danger-soft: #fff0ee;
  --info: #1e67a8;
  --info-soft: #edf6ff;
  --order-status-chip-sales-pending-text: #1e5a96;
  --order-status-chip-sales-pending-bg: #e8f2fc;
  --order-status-chip-manager-text: #6d3fa0;
  --order-status-chip-manager-bg: #f2eafe;
  --order-status-chip-logistics-text: #9a5a00;
  --order-status-chip-logistics-bg: #fff2d8;
  --order-status-chip-finance-text: #087a78;
  --order-status-chip-finance-bg: #e6f7f5;
  --order-status-chip-rejected-text: #b42318;
  --order-status-chip-rejected-bg: #fff0ee;
  --order-status-chip-locked-text: #187451;
  --order-status-chip-locked-bg: #eaf7f0;
  --order-status-chip-voided-text: #596779;
  --order-status-chip-voided-bg: #edf1f5;
  --order-status-chip-returned-text: #8b4513;
  --order-status-chip-returned-bg: #fff4df;
  --focus: #2684ff;
  --focus-ring: rgba(38, 132, 255, 0.24);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --control-sm: 32px;
  --data-loading-font-size: 13px;
  --control-md: 40px;
  --control-lg: 44px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.14);
  --duration-fast: 160ms;
  --duration-base: 220ms;
  --page-inline-gutter: clamp(20px, 1.45vw, 36px);
  --z-sticky: 30;
  --z-dropdown: 70;
  --z-expanded-view: 90;
  --z-modal: 100;
  --z-toast: 120;
  --z-screen-lock: 2000;
  --modal-header-min-height: 72px;
  --modal-close-size: 40px;
  --modal-mobile-gutter: 12px;
  --modal-desktop-gutter: 20px;
  --modal-action-gap: 8px;
  --modal-action-min-height: 44px;
  --modal-action-padding-block: 10px;
  --pagination-control-height: 40px;
  --pagination-nav-min-width: 76px;

  /* Backward-compatible aliases. */
  --bg: var(--surface-page);
  --panel: var(--surface-panel);
  --panel-soft: var(--surface-subtle);
  --ink: var(--text);
  --muted: var(--text-secondary);
  --line: var(--border);
  --blue: var(--brand);
  --blue-weak: var(--brand-soft);
  --red: var(--danger);
  --red-weak: var(--danger-soft);
  --green: var(--success);
  --green-weak: var(--success-soft);
  --gold: var(--warning);
  --gold-weak: var(--warning-soft);
  --shadow: var(--shadow-md);
}

html { scroll-padding-top: 96px; }

body {
  color: var(--text);
  background: var(--surface-page);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 700; text-wrap: balance; }
h1 { font-size: 24px; line-height: 1.3; }
h2 { font-size: 20px; line-height: 1.35; }
h3 { font-size: 16px; line-height: 1.4; }
p { text-wrap: pretty; }

.ui-data-loading { padding: var(--space-6); color: var(--text-secondary); text-align: center; }
.ui-data-loading-value { font-size: var(--data-loading-font-size); color: var(--text-secondary); }
.ui-data-load-error { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3); color: var(--danger); flex-wrap: wrap; }
.ui-data-loading-row > td { display: table-cell !important; }

:where(input, select, textarea, button) { font-family: inherit; }
:where(input, select, textarea) { font-size: 14px; }
:where(input, select, textarea):focus-visible,
:where(button, a, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
  border-color: var(--focus) !important;
}

:where(input, select, textarea)[aria-invalid="true"],
:where(input, select, textarea).is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12) !important;
}

.ledger-adjustment-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.ledger-adjustment-preview > div {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.ledger-adjustment-preview span,
.ledger-adjust-fund-option small {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 400;
}

.ledger-adjustment-preview strong {
  font-variant-numeric: tabular-nums;
}

.ledger-adjust-fund-option {
  align-items: flex-start;
  padding: var(--space-3);
  background: var(--warning-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.ledger-adjust-fund-option > span {
  display: grid;
  gap: var(--space-1);
}

.ledger-adjust-fund-option input {
  margin-top: var(--space-1);
}

:where(input, select, textarea):disabled {
  color: var(--text-secondary);
  background: var(--surface-muted);
  border-color: var(--border);
  opacity: 1;
  cursor: not-allowed;
}

.workspace > main,
.workspace > .content,
.view-container {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin-inline: 0;
}

.topbar { z-index: var(--z-sticky); min-height: 72px; }
.sidebar { background: #172033; }
.nav-item { min-height: var(--control-lg); border-radius: var(--radius-md); transition: color var(--duration-fast), background var(--duration-fast); }

:where(.icon-btn, .action-btn, .small-btn, .btn) {
  min-height: var(--control-md);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}

:where(.icon-btn, .small-btn, .btn.ghost) { background: var(--surface-panel); }
:where(.icon-btn, .small-btn, .btn.ghost):hover { background: var(--surface-subtle); border-color: var(--border-strong); }
:where(.action-btn.primary, .small-btn.primary, .btn.primary) { color: #fff; background: var(--brand); border-color: var(--brand); }
:where(.action-btn.primary, .small-btn.primary, .btn.primary):hover { color: #fff; background: var(--brand-hover); border-color: var(--brand-hover); }
:where(.action-btn.primary, .small-btn.primary, .btn.primary):active { color: #fff; background: var(--brand-active); border-color: var(--brand-active); }
:where(.action-btn.success, .small-btn.success, .btn.success) { color: #fff; background: var(--success); border-color: var(--success); }
:where(.action-btn.success, .small-btn.success, .btn.success):hover,
:where(.action-btn.success, .small-btn.success, .btn.success):active { color: #fff; background: #125e41; border-color: #125e41; }
:where(button.danger, .action-btn.danger, .danger-btn, .btn.danger, .small-btn.danger) { color: var(--danger); background: var(--surface-panel); border-color: #efb6b0; }
:where(button.danger, .action-btn.danger, .danger-btn, .btn.danger, .small-btn.danger):hover { color: #fff; background: var(--danger); border-color: var(--danger); }
:where(button, .btn)[disabled], :where(button, .btn).is-loading { opacity: .62; cursor: wait; pointer-events: none; }

.small-btn { min-height: var(--control-sm); padding-inline: 10px; font-size: 13px; }
.icon-btn { width: var(--control-md); height: var(--control-md); min-height: var(--control-md); padding: 0; }

:where(.search-input, .field input, .field select, .field textarea, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
  border-color: var(--border);
  border-radius: var(--radius-md);
}

:where(.search-input, .field input, .field select, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select) { min-height: var(--control-md); }
:where(.field textarea, textarea) { min-height: 88px; }
.field { gap: 6px; }
.field :where(label, > span) { color: var(--text-secondary); font-size: 13px; font-weight: 600; line-height: 1.4; }
:where(.compact.muted, .field small, .helper-text, .form-help) { color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
:where(.form-error, .field-error) { color: var(--danger); font-size: 12px; line-height: 1.45; }

.panel,
.card,
.order-entry-section,
.order-main,
.modal,
.ui-card,
.ui-section {
  border-color: var(--border);
  border-radius: var(--radius-lg);
}

.order-main { gap: var(--space-5); padding: var(--space-5); background: var(--surface-subtle); }
.order-entry-section { padding: var(--space-4); box-shadow: var(--shadow-sm); }
.order-entry-title { padding-bottom: var(--space-3); }
.order-entry-title-meta { font-size: 12px; }
.order-workbench-hero .compact { font-size: 12px; }

.section-title-row,
.order-entry-title,
.proof-group-head,
.modal-header { min-height: 44px; align-items: center; }

.order-step-shell { gap: var(--space-4); }
.order-step-nav { top: 80px; gap: var(--space-2); padding: var(--space-2); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.order-step-btn { min-height: 52px; border-radius: var(--radius-md); }
.order-step-btn strong { font-size: 14px; }
.order-step-state { font-size: 11px; }

.sale-settlement-extra { gap: var(--space-3); padding-top: var(--space-4); }
.sale-settlement-extra-head > div > strong { font-size: 16px; }
.sale-settlement-extra-head > div > span { font-size: 12px; }
.sale-settlement-row { gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-lg); }

.packing-items-editor { gap: var(--space-3); padding: 0; background: transparent; border: 0; }
.packing-item-row { padding: var(--space-3); border-radius: var(--radius-md); }
.packing-aggregate-summary { gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-md); }

.other-add-actions { gap: var(--space-3); padding: 0; background: transparent; border: 0; }
.other-add-card { border-radius: var(--radius-md); }
.other-empty-state { border-radius: var(--radius-md); }

.table-wrap,
.data-table-wrap { max-width: 100%; overflow: auto; overscroll-behavior-inline: contain; }
:where(table) { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
:where(th) { color: var(--text-secondary); font-size: 13px; font-weight: 650; }
:where(th, td) { min-height: var(--control-lg); }

.modal-backdrop {
  z-index: var(--z-modal);
  padding: var(--space-5);
  background: rgba(15, 23, 42, .52);
}
.modal {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-panel);
  box-shadow: var(--shadow-lg);
}

/*
 * Unified dialog chrome. All business dialogs share the same hierarchy:
 * title + short introduction on the left, close/action control on the right.
 */
:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) {
  min-height: var(--modal-header-min-height);
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start !important;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-panel);
}

:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) > :first-child {
  min-width: 0;
}

:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) > .button-row {
  margin: 0;
  place-self: start end;
}

:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) :where(h1, h2, h3) {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) :where(.compact.muted, .modal-description) {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) > :where(.icon-btn, .modal-close-button),
:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) > .button-row > :where(.icon-btn, .modal-close-button) {
  width: var(--modal-close-size);
  min-width: var(--modal-close-size);
  height: var(--modal-close-size);
  min-height: var(--modal-close-size);
  margin: 0;
  padding: 0;
  place-self: start end;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-panel);
  color: var(--text-secondary);
}

:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) > :where(.icon-btn, .modal-close-button):hover,
:where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) > .button-row > :where(.icon-btn, .modal-close-button):hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text);
}

.modal-body { min-height: 0; padding: var(--space-5); overflow: auto; overscroll-behavior: contain; }

/* Unified list pagination. */
.pagination {
  display: grid !important;
  min-height: 64px;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}
.pagination-summary { gap: var(--space-2); font-size: 13px; }
.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}
.pagination-nav-button {
  min-width: var(--pagination-nav-min-width);
  min-height: var(--pagination-control-height);
  padding-inline: var(--space-3);
  justify-content: center;
  border-radius: var(--radius-md);
}
.page-jump {
  min-height: var(--pagination-control-height);
  padding: 3px;
  border-color: var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-panel);
}
.page-jump input { min-height: 32px; }
.page-jump .pagination-jump-button { min-height: 32px; border-radius: var(--radius-sm); }

.toast {
  z-index: var(--z-toast);
  max-width: min(420px, calc(100vw - 24px));
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  line-height: 1.45;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

.ui-stack { display: grid; gap: var(--space-4); }
.ui-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.ui-card { padding: var(--space-4); background: var(--surface-panel); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.ui-section { padding: var(--space-5); background: var(--surface-panel); border: 1px solid var(--border); }
.ui-status { min-height: 28px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; }
.ui-status.info { color: var(--info); background: var(--info-soft); }
.ui-status.success { color: var(--success); background: var(--success-soft); }
.ui-status.warning { color: var(--warning); background: var(--warning-soft); }
.ui-status.danger { color: var(--danger); background: var(--danger-soft); }

@media (max-width: 1024px) {
  .order-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  body { font-size: 14px; }
  h1 { font-size: 20px; }
  h2 { font-size: 18px; }
  .topbar { min-height: 60px; padding: 10px 12px; }
  .order-main { gap: var(--space-4); padding: var(--space-3); }
  .order-entry-section, .ui-card, .ui-section { padding: var(--space-3); }
  .order-step-nav { top: 60px; gap: 4px; padding: 4px; overflow-x: auto; scrollbar-width: none; }
  .order-step-nav::-webkit-scrollbar { display: none; }
  .order-step-btn { min-width: 88px; min-height: 48px; grid-template-columns: 1fr; justify-items: center; gap: 2px; padding: 6px 4px; text-align: center; }
  .order-step-index { width: 20px; height: 20px; font-size: 11px; }
  .order-step-btn strong { font-size: 12px; }
  .order-step-state { min-width: 0; padding: 2px 5px; font-size: 10px; }
  .packing-item-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .packing-item-remark-field { grid-column: 1 / -1; }
  .packing-aggregate-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: var(--space-2); }
  .packing-aggregate-summary > * { min-width: 0; font-size: 11px; overflow-wrap: anywhere; }
  .sale-settlement-extra-head { flex-direction: column; align-items: stretch; }
  .sale-settlement-extra-head .small-btn { align-self: flex-start; }
  .modal-backdrop { padding: 0; }
  .modal { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  :where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) {
    min-height: calc(var(--modal-header-min-height) + env(safe-area-inset-top));
    grid-template-columns: minmax(0, 1fr) var(--modal-close-size);
    align-items: start !important;
    flex-direction: row !important;
    gap: var(--space-2);
    padding: max(var(--modal-mobile-gutter), env(safe-area-inset-top)) var(--modal-mobile-gutter) var(--modal-mobile-gutter);
  }
  :where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) :where(h1, h2, h3) { font-size: 18px; }
  :where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) :where(.compact.muted, .modal-description) {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .modal-body { padding: var(--modal-mobile-gutter); }
  .pagination { grid-template-columns: 1fr; gap: var(--space-2); padding: var(--space-2); }
  .pagination-summary { justify-content: center; min-height: 24px; }
  .pagination-controls {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(var(--pagination-nav-min-width), 1fr) auto minmax(var(--pagination-nav-min-width), 1fr);
    gap: 6px;
  }
  .pagination-nav-button { width: 100%; min-width: 0; min-height: var(--pagination-control-height); padding-inline: 6px; }
  .pagination-pair .pagination-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-jump { min-width: 0; justify-content: center; }
  :where(.action-btn, .btn) { min-height: var(--control-lg); }
}

@media (max-width: 420px) {
  .packing-item-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .packing-item-card-grid .field { min-width: 0; }
  .packing-item-card-grid :where(input, select) { min-width: 0; }
}

/* Unified modal viewport and action contract.
 * This final layer is intentionally authoritative: feature styles may choose a
 * desktop width, but must not redefine the mobile frame or footer behavior.
 */
.modal-backdrop > .modal {
  max-height: calc(100dvh - (var(--modal-desktop-gutter) * 2));
}

/* Payment requests can contain several conditional sections. Keep the shared
 * desktop dialog chrome inside the viewport and scroll only its body instead
 * of letting the long form determine the outer dialog height. */
.modal-backdrop > .payment-modal {
  max-height: min(900px, calc(100dvh - (var(--modal-desktop-gutter) * 2)));
  grid-template-rows: auto minmax(0, 1fr);
}

.modal-backdrop > .payment-modal > .modal-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 780px) {
  .modal-backdrop {
    padding: 0 !important;
    place-items: stretch !important;
  }

  .modal-backdrop > .modal {
    display: flex !important;
    flex-direction: column !important;
    width: 100vw !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  .modal-backdrop > .modal > :where(.modal-header, .modal-head, .order-modal-header, .payment-modal-header, .record-modal-header) {
    flex: 0 0 auto !important;
  }

  .modal-backdrop > .modal > .modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding-bottom: calc(
      var(--modal-action-min-height)
      + (var(--modal-action-padding-block) * 2)
      + var(--modal-action-gap)
      + env(safe-area-inset-bottom)
    ) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .modal-backdrop > .modal > .modal-body:has(:where(
    .modal-actions,
    .modal-footer,
    .payment-modal-actions,
    .payment-detail-actions,
    .finance-ledger-modal-actions,
    .amap-picker-actions,
    .payment-order-picker-footer
  ) > :nth-child(5)) {
    padding-bottom: calc(
      (var(--modal-action-min-height) * 2)
      + (var(--modal-action-padding-block) * 2)
      + (var(--modal-action-gap) * 2)
      + env(safe-area-inset-bottom)
    ) !important;
  }

  .modal-backdrop > .modal :where(
    .modal-actions,
    .modal-footer,
    .payment-modal-actions,
    .payment-detail-actions,
    .finance-ledger-modal-actions,
    .amap-picker-actions,
    .payment-order-picker-footer
  ) {
    position: fixed !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: calc(var(--z-sticky) + 1) !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: var(--modal-action-padding-block) var(--modal-mobile-gutter) max(var(--modal-action-padding-block), env(safe-area-inset-bottom)) !important;
    gap: var(--modal-action-gap) !important;
    box-sizing: border-box !important;
    background: rgba(255, 255, 255, 0.98) !important;
    border: 0 !important;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 !important;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08) !important;
    backdrop-filter: blur(10px);
  }

  .modal-backdrop > .modal :where(
    .modal-actions,
    .modal-footer,
    .payment-modal-actions,
    .payment-detail-actions,
    .finance-ledger-modal-actions,
    .amap-picker-actions,
    .payment-order-picker-footer
  ) > :where(button, .btn, .action-btn, a) {
    flex: 1 1 calc(25% - (var(--modal-action-gap) * 0.75)) !important;
    min-width: 0 !important;
    min-height: var(--modal-action-min-height) !important;
    margin: 0 !important;
    padding-inline: 8px !important;
    font-size: clamp(11px, 3.2vw, 14px) !important;
    line-height: 1.2 !important;
    text-align: center;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  /*
   * Notification dialogs are short, content-driven lists rather than data-entry
   * flows. Keep the shared mobile header/action styling, but do not force the
   * dialog body to fill the viewport when only a few messages are present.
   */
  .modal-backdrop > .notification-modal {
    place-self: start stretch !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: 100dvh !important;
  }

  .modal-backdrop > .notification-modal > .modal-body {
    display: flex !important;
    flex: 0 1 auto !important;
    flex-direction: column !important;
    gap: var(--modal-action-gap) !important;
    min-height: 0 !important;
    padding-bottom: var(--modal-mobile-gutter) !important;
    overflow: hidden !important;
  }

  .notification-modal .notification-list {
    flex: 0 1 auto;
    max-height: calc(
      100dvh
      - 104px
      - var(--modal-action-min-height)
      - (var(--modal-action-padding-block) * 2)
      - (var(--modal-mobile-gutter) * 2)
      - env(safe-area-inset-bottom)
    );
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .modal-backdrop > .notification-modal .modal-actions {
    position: static !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: none !important;
    padding: var(--modal-action-padding-block) 0 max(var(--modal-action-padding-block), env(safe-area-inset-bottom)) !important;
    background: transparent !important;
    border-top: 1px solid var(--border) !important;
    box-shadow: none !important;
    backdrop-filter: none;
  }
}

/* Finance work modal suite.
 * Shared structure for settlement data, manual fund entries, customer ledger
 * registration and supplier records. Business rules stay in app.js; this layer
 * only standardizes hierarchy, density and responsive behavior.
 */
#view[data-view="finance"] .finance-panel-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

#view[data-view="finance"] .finance-panel-heading {
  min-width: 0;
}

#view[data-view="finance"] .finance-entry-actions {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#view[data-view="finance"] .finance-entry-button {
  min-width: 0;
  min-height: 44px;
  display: inline-grid;
  grid-template-columns: 20px minmax(0, auto) 16px;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: var(--radius-md);
  box-shadow: 0 5px 14px rgba(20, 93, 165, .18);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

#view[data-view="finance"] .finance-entry-button:hover {
  color: #fff;
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  box-shadow: 0 7px 18px rgba(20, 93, 165, .24);
  transform: translateY(-1px);
}

#view[data-view="finance"] .finance-entry-button:active {
  background: var(--brand-active);
  border-color: var(--brand-active);
  box-shadow: 0 3px 9px rgba(20, 93, 165, .2);
  transform: translateY(0);
}

#view[data-view="finance"] .finance-entry-button:focus-visible {
  outline: 3px solid rgba(20, 93, 165, .24);
  outline-offset: 2px;
}

#view[data-view="finance"] .finance-entry-button svg {
  width: 18px;
  height: 18px;
}

#view[data-view="finance"] .finance-entry-button svg:last-child {
  width: 15px;
  height: 15px;
  opacity: .78;
}

.finance-work-modal {
  --finance-modal-accent: var(--brand);
  --finance-modal-accent-soft: var(--brand-soft);
}

.finance-work-modal.finance-ledger-entry-modal,
.finance-fund-entry-modal {
  width: min(800px, calc(100vw - (var(--modal-desktop-gutter) * 2)));
}

.finance-supplier-edit-modal {
  width: min(940px, calc(100vw - (var(--modal-desktop-gutter) * 2)));
}

.finance-directory-modal {
  width: min(1180px, calc(100vw - (var(--modal-desktop-gutter) * 2)));
}

.finance-simple-modal {
  width: min(620px, calc(100vw - (var(--modal-desktop-gutter) * 2)));
}

.finance-work-modal > :where(.modal-header, .record-modal-header) {
  padding: 18px 20px;
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}

.finance-modal-heading {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.finance-modal-heading > div {
  min-width: 0;
}

.finance-modal-heading-icon,
.finance-form-section-head > span,
.finance-directory-toolbar-icon {
  display: grid;
  place-items: center;
  color: var(--finance-modal-accent);
  background: var(--finance-modal-accent-soft);
  border: 1px solid #cfe1f4;
}

.finance-modal-heading-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.finance-modal-heading-icon svg {
  width: 20px;
  height: 20px;
}

.finance-modal-kicker {
  margin: 0 0 2px;
  color: var(--finance-modal-accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
}

.finance-work-modal .modal-description {
  max-width: 720px;
}

.finance-work-modal > .modal-body,
.finance-work-modal > .finance-ledger-entry-form {
  background: var(--surface-subtle);
}

.finance-work-modal .finance-modal-body {
  background: var(--surface-subtle);
}

.finance-work-form,
.finance-simple-modal-body,
.finance-work-modal .finance-ledger-entry-form {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px 20px 0;
}

.finance-simple-modal-body > .modal-form {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 14px;
}

.finance-form-section {
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.finance-form-section-head {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.finance-form-section-head > span,
.finance-directory-toolbar-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
}

.finance-form-section-head > span svg,
.finance-directory-toolbar-icon svg {
  width: 17px;
  height: 17px;
}

.finance-form-section-head > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.finance-form-section-head strong {
  color: var(--text);
  font-size: 14px;
}

.finance-form-section-head small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.finance-form-callout {
  min-width: 0;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  color: var(--info);
  background: var(--info-soft);
  border: 1px solid #cfe1f4;
  border-radius: var(--radius-md);
}

.finance-form-callout.warning {
  color: #7b4a0d;
  background: var(--warning-soft);
  border-color: #efd9ac;
}

.finance-form-callout > svg {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.finance-form-callout > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.finance-form-callout strong {
  font-size: 13px;
}

.finance-form-callout span {
  font-size: 12px;
  line-height: 1.5;
}

.finance-work-modal .finance-modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 -20px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .05);
  backdrop-filter: blur(10px);
}

.finance-work-modal .finance-modal-actions > :where(button, .btn, .action-btn) {
  min-width: 112px;
  justify-content: center;
}

.finance-work-modal .ledger-entry-step {
  min-width: 0;
  grid-template-columns: 158px minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.finance-work-modal .ledger-entry-step + .ledger-entry-step {
  margin-top: 0;
}

.finance-work-modal .ledger-entry-step-head > span {
  background: var(--finance-modal-accent);
  box-shadow: 0 0 0 4px var(--finance-modal-accent-soft);
}

.finance-work-modal .ledger-fixed-context {
  min-height: 72px;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-color: var(--border);
  border-radius: var(--radius-md);
}

.finance-work-modal .ledger-adjustment-preview {
  background: var(--info-soft);
  border-color: #cfe1f4;
}

.finance-work-modal .supplier-status-option {
  min-height: 60px;
  align-items: center;
  padding: 10px 12px;
  background: var(--success-soft);
  border: 1px solid #c9e8d7;
  border-radius: var(--radius-md);
}

.finance-work-modal .supplier-status-option > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.finance-work-modal .supplier-status-option small {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

.finance-work-modal .supplier-payment-account-editor {
  margin-top: 0;
  padding: 16px;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.finance-work-modal .supplier-payment-account-heading > div {
  gap: 3px;
}

.finance-work-modal .supplier-payment-account-heading strong {
  color: var(--text);
  font-size: 14px;
}

.finance-work-modal .supplier-payment-account-row {
  gap: 12px;
  padding: 14px;
  background: var(--surface-subtle);
  border-color: var(--border);
  border-radius: var(--radius-md);
}

.finance-work-modal .supplier-payment-account-empty {
  min-height: 112px;
  background: var(--surface-subtle);
  border-color: var(--border-strong);
}

.finance-work-modal .finance-modal-section {
  min-width: 0;
  gap: 14px;
  padding: 16px;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.finance-work-modal .ledger-entry-step.finance-modal-section {
  grid-template-columns: minmax(0, 1fr);
}

.finance-work-modal .ledger-entry-step-head {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.finance-work-modal .ledger-entry-step-head > span {
  width: 34px;
  height: 34px;
  color: var(--finance-modal-accent);
  background: var(--finance-modal-accent-soft);
  border: 1px solid #cfe1f4;
  border-radius: var(--radius-md);
  box-shadow: none;
}

.finance-work-modal .ledger-entry-step-head strong {
  font-size: 14px;
}

.finance-work-modal .ledger-entry-step-head small {
  font-size: 12px;
  line-height: 1.45;
}

.finance-work-modal .finance-form-section-head-action {
  grid-template-columns: 34px minmax(0, 1fr) auto;
}

.finance-work-modal .finance-form-section-head-action > .small-btn {
  min-height: 38px;
  justify-content: center;
}

.finance-work-modal .supplier-payment-account-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.finance-directory-modal .directory-modal-body {
  gap: 14px;
  align-content: start;
  padding: 0 20px 20px;
  background: var(--surface-panel);
}

.finance-directory-toolbar {
  grid-template-columns: minmax(280px, 1fr) auto auto;
  gap: 10px;
  padding: 14px 0;
  background: transparent;
  border-width: 0 0 1px;
  border-radius: 0;
}

.finance-directory-toolbar .directory-command-search {
  min-height: 42px;
  background: var(--surface-subtle);
  border-color: var(--border);
  border-radius: var(--radius-md);
}

.finance-record-count {
  min-width: 80px;
  min-height: 40px;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  padding: 0 10px;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.finance-record-count strong {
  color: var(--text);
  font-size: 15px;
}

.finance-record-count small {
  font-size: 11px;
}

.supplier-directory-overview {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.supplier-directory-overview > div {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  color: var(--text-secondary);
  border-left: 1px solid var(--border);
  font-size: 12px;
}

.supplier-directory-overview > div:first-child {
  border-left: 0;
}

.supplier-directory-overview strong {
  color: var(--text);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.supplier-directory-overview .is-active strong {
  color: var(--success);
}

.supplier-directory-overview .is-inactive strong,
.supplier-directory-overview .is-deleted strong {
  color: var(--text-secondary);
}

.supplier-directory-overview .is-pending strong {
  color: var(--warning);
}

.supplier-directory-desktop-identity {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.supplier-directory-desktop-identity > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid #cfe1f4;
  border-radius: var(--radius-sm);
}

.supplier-directory-desktop-identity svg {
  width: 15px;
  height: 15px;
}

.supplier-directory-desktop-identity strong {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.supplier-directory-account-summary {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.supplier-directory-account-summary strong {
  color: var(--text);
  font-size: 13px;
}

.supplier-directory-account-summary span {
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

.supplier-directory-modal .directory-remark-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-directory-modal .directory-updated-cell {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.supplier-directory-mobile-card {
  display: none;
}

@media (min-width: 781px) {
  .finance-directory-modal.supplier-directory-modal {
    height: min(820px, calc(100dvh - (var(--modal-desktop-gutter) * 2)));
  }

  .supplier-directory-modal .directory-modal-body {
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .supplier-directory-modal .finance-directory-content {
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
}

.finance-directory-modal .directory-modal-table {
  max-height: min(56vh, 600px);
  border-color: var(--border);
  border-radius: var(--radius-md);
}

.finance-directory-modal .finance-directory-content {
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.finance-settlement-directory-modal .finance-directory-content {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.finance-settlement-directory-modal .finance-directory-content .directory-modal-table {
  border-radius: var(--radius-md);
}

.finance-directory-modal .directory-record-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.finance-directory-modal .directory-record-table th {
  height: 42px;
  padding: 10px 12px;
  background: var(--surface-muted);
  border-color: var(--border);
}

.finance-directory-modal .directory-record-table td {
  min-height: 48px;
  padding: 10px 12px;
  font-size: 13px;
  border-color: var(--border);
}

.finance-directory-modal .directory-record-table tbody tr:hover {
  background: var(--surface-subtle);
}

.finance-directory-modal .directory-actions-cell .button-row {
  flex-wrap: nowrap;
}

.finance-directory-modal .pagination {
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.finance-settlement-directory-modal .settlement-directory-command {
  grid-template-columns: minmax(260px, 1fr) auto auto;
}

.finance-settlement-directory-modal .directory-command-title {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.finance-settlement-directory-modal .directory-command-title > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.finance-settlement-directory-modal .directory-command-title small {
  color: var(--text-secondary);
  font-size: 12px;
}

@media (max-width: 780px) {
  #view[data-view="finance"] .finance-panel-toolbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  #view[data-view="finance"] .finance-entry-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    justify-content: stretch;
  }

  #view[data-view="finance"] .finance-entry-button {
    width: 100%;
    min-height: 42px;
  }

  .finance-work-modal > :where(.modal-header, .record-modal-header) {
    padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  }

  .finance-modal-heading {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
  }

  .finance-modal-heading-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
  }

  .finance-modal-heading-icon svg {
    width: 18px;
    height: 18px;
  }

  .finance-work-form,
  .finance-simple-modal-body,
  .finance-work-modal .finance-ledger-entry-form {
    gap: 10px;
    padding: 12px;
  }

  .finance-form-section,
  .finance-work-modal .supplier-payment-account-editor,
  .finance-work-modal .ledger-entry-step {
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
  }

  .finance-work-modal .ledger-entry-step {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .finance-work-modal .ledger-entry-step-head {
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: center;
  }

  .finance-work-modal .ledger-entry-step-head > span {
    width: 32px;
    height: 32px;
  }

  .finance-work-modal .finance-modal-actions > :where(button, .btn, .action-btn) {
    min-width: 0;
  }

  .finance-directory-modal .directory-modal-body {
    gap: 10px;
    padding: 0 12px 12px;
    background: var(--surface-subtle);
  }

  .finance-directory-toolbar,
  .finance-settlement-directory-modal .settlement-directory-command {
    position: sticky;
    top: 0;
    z-index: 4;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px 0;
    background: rgba(248, 250, 252, .98);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
  }

  .finance-directory-toolbar .directory-command-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .finance-directory-toolbar .directory-command-actions select {
    min-width: 0;
    width: 100%;
  }

  .finance-directory-toolbar > .action-btn {
    width: 100%;
    justify-content: center;
  }

  .finance-record-count {
    min-width: 84px;
  }

  .finance-directory-modal .directory-modal-table {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .finance-directory-modal .finance-directory-content,
  .finance-settlement-directory-modal .finance-directory-content {
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }

  .finance-directory-modal .directory-record-table tr {
    gap: 10px 12px;
    padding: 12px;
    background: var(--surface-panel);
    border-color: var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  .finance-directory-modal .directory-record-table td {
    min-height: 0;
    padding: 0;
    font-size: 13px;
  }

  .finance-directory-modal .supplier-directory-table tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-directory-modal .supplier-directory-table .directory-name-cell {
    grid-column: 1;
  }

  .finance-directory-modal .supplier-directory-table .directory-status-cell {
    grid-column: 2;
    justify-items: end;
  }

  .finance-directory-modal .supplier-directory-table :where(.directory-remark-cell, .directory-actions-cell) {
    grid-column: 1 / -1;
  }

  .finance-directory-modal .directory-actions-cell .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .finance-directory-modal .directory-actions-cell .small-btn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
  }

  .supplier-directory-modal .supplier-directory-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .supplier-directory-modal .supplier-directory-toolbar .directory-command-search {
    grid-column: 1;
    min-height: 40px;
  }

  .supplier-directory-modal .supplier-directory-toolbar .directory-command-search #supplier-directory-query {
    grid-column: auto;
  }

  .supplier-directory-modal .supplier-directory-toolbar .directory-command-actions {
    grid-column: 1 / -1;
  }

  .supplier-directory-modal .supplier-directory-toolbar .supplier-directory-create {
    grid-column: 2;
    grid-row: 1;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
  }

  .supplier-directory-modal .supplier-directory-create span {
    display: none;
  }

  .supplier-directory-overview {
    min-height: 45px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-radius: var(--radius-md);
  }

  .supplier-directory-overview > div {
    min-height: 45px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 1px;
    padding: 5px 3px;
    text-align: center;
  }

  .supplier-directory-overview span {
    min-width: 0;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .supplier-directory-overview strong {
    font-size: 15px;
    line-height: 1.1;
  }

  .finance-directory-modal .supplier-directory-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0;
    overflow: hidden;
    box-shadow: none;
  }

  .finance-directory-modal .supplier-directory-table .directory-name-cell {
    grid-column: 1 / -1;
    padding: 12px;
  }

  .supplier-directory-desktop-identity {
    display: none;
  }

  .supplier-directory-mobile-card {
    min-width: 0;
    display: grid;
  }

  .supplier-directory-mobile-head {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    padding-bottom: 10px;
  }

  .supplier-directory-mobile-identity {
    min-width: 0;
    display: grid;
    gap: 4px;
  }

  .supplier-directory-mobile-identity strong {
    min-width: 0;
    display: -webkit-box;
    overflow: hidden;
    color: var(--text);
    font-size: 15px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .supplier-directory-mobile-identity small {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .supplier-directory-mobile-identity small svg {
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
  }

  .supplier-directory-mobile-head .status-chip {
    min-height: 24px;
    padding: 3px 8px;
    white-space: nowrap;
  }

  .supplier-directory-mobile-facts {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .supplier-directory-mobile-facts > div {
    min-width: 0;
    min-height: 62px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 2px;
    padding: 7px 5px;
    border-left: 1px solid var(--border);
    text-align: center;
  }

  .supplier-directory-mobile-facts > div:first-child {
    border-left: 0;
  }

  .supplier-directory-mobile-facts span,
  .supplier-directory-mobile-facts small {
    min-width: 0;
    color: var(--text-secondary);
    font-size: 10px;
    line-height: 1.2;
  }

  .supplier-directory-mobile-facts strong {
    min-width: 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .supplier-directory-mobile-facts .is-pending strong {
    color: var(--warning);
  }

  .supplier-directory-mobile-remark {
    min-width: 0;
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr);
    gap: 6px;
    align-items: center;
    padding-top: 9px;
    color: var(--text-secondary);
    font-size: 11px;
  }

  .supplier-directory-mobile-remark svg {
    width: 14px;
    height: 14px;
  }

  .supplier-directory-mobile-remark span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .finance-directory-modal .supplier-directory-table :where(
    .directory-credit-cell,
    .directory-status-cell,
    .directory-account-cell,
    .directory-history-cell,
    .directory-remark-cell,
    .directory-updated-cell
  ) {
    display: none;
  }

  .finance-directory-modal .supplier-directory-table .directory-actions-cell {
    grid-column: 1 / -1;
    padding: 0;
    border-top: 1px solid var(--border);
  }

  .finance-directory-modal .supplier-directory-table .directory-actions-cell::before {
    display: none;
  }

  .finance-directory-modal .supplier-directory-table .directory-actions-cell.is-readonly {
    display: none;
  }

  .finance-directory-modal .supplier-directory-table .directory-actions-cell .button-row {
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    gap: 0;
  }

  .finance-directory-modal .supplier-directory-table .directory-actions-cell .small-btn {
    min-height: 40px;
    border-width: 0 0 0 1px;
    border-radius: 0;
    background: transparent;
  }

  .finance-directory-modal .supplier-directory-table .directory-actions-cell .small-btn:first-child {
    border-left: 0;
  }

  .finance-directory-modal .supplier-directory-table .directory-actions-cell .small-btn.danger {
    color: var(--danger);
  }

  .supplier-directory-modal .modal-description {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .finance-directory-modal .pagination {
    border-radius: var(--radius-md);
  }

  .finance-settlement-directory-modal .directory-command-title {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .finance-settlement-directory-modal .directory-command-actions {
    display: flex;
    justify-content: flex-start;
  }
}

@media (min-width: 781px) and (max-width: 1100px) {
  .supplier-directory-modal .directory-actions-cell .small-btn {
    min-width: 0;
    gap: 0;
    padding-inline: 6px;
    font-size: 11px;
  }

  .supplier-directory-modal .directory-actions-cell .small-btn svg {
    display: none;
  }
}

@media (max-width: 560px) {
  .finance-work-modal :where(.form-grid.two, #finance-ledger-form .ledger-entry-fields, .supplier-payment-account-grid) {
    grid-template-columns: minmax(0, 1fr);
  }

  .finance-work-modal :where(.form-grid.two, #finance-ledger-form .ledger-entry-fields, .supplier-payment-account-grid) > * {
    grid-column: 1 / -1;
  }

  .finance-work-modal .supplier-payment-account-heading {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .finance-work-modal .supplier-payment-account-heading > .small-btn {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 40px;
    justify-content: center;
  }
}

@media (min-width: 781px) and (max-width: 1400px) {
  #view[data-view="finance"] .finance-panel-toolbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  #view[data-view="finance"] .finance-entry-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 380px) {
  .finance-modal-kicker {
    display: none;
  }

  .finance-form-section-head {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .finance-form-section-head > span {
    width: 30px;
    height: 30px;
  }
}

/* Finance main pages: one hierarchy and a compact, readable mobile rhythm. */
#view[data-view="finance"] .finance-filter-toggle {
  display: none;
}

#view[data-view="finance"] .finance-page-panel {
  border-color: var(--border);
}

#view[data-view="finance"] .finance-panel-heading h2 {
  letter-spacing: -.02em;
}

#view[data-view="finance"] .ledger-card-table :where(td, th) {
  font-variant-numeric: tabular-nums;
}

#view[data-view="finance"] .ledger-card-table tbody tr:hover {
  background: #f8fbff;
}

/* Actual fund flow: stable desktop columns and a compact transaction hierarchy. */
#view[data-view="finance"] .finance-real-fund-flow {
  display: grid;
  gap: 12px;
}

#view[data-view="finance"] .real-fund-flow-toolbar {
  min-height: 48px;
  align-items: center;
  margin: 0;
}

#view[data-view="finance"] .real-fund-flow-toolbar h2 {
  margin: 0 0 3px;
  letter-spacing: -.02em;
}

#view[data-view="finance"] .real-fund-flow-toolbar p {
  margin: 0;
}

#view[data-view="finance"] .real-fund-flow-count {
  min-height: 30px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 5px 9px;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

#view[data-view="finance"] .real-fund-flow-count strong {
  color: var(--brand);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#view[data-view="finance"] .real-fund-flow-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

#view[data-view="finance"] .real-fund-flow-table {
  min-width: 960px;
  table-layout: fixed;
}

#view[data-view="finance"] .real-fund-flow-table :is(th, td):nth-child(1) { width: 108px; }
#view[data-view="finance"] .real-fund-flow-table :is(th, td):nth-child(2) { width: 22%; }
#view[data-view="finance"] .real-fund-flow-table :is(th, td):nth-child(3) { width: 118px; }
#view[data-view="finance"] .real-fund-flow-table :is(th, td):nth-child(4) { width: 138px; }
#view[data-view="finance"] .real-fund-flow-table :is(th, td):nth-child(5) { width: 150px; }

#view[data-view="finance"] .real-fund-flow-table tbody td {
  vertical-align: middle;
}

#view[data-view="finance"] .real-fund-flow-date time,
#view[data-view="finance"] .real-fund-flow-amount > strong,
#view[data-view="finance"] .real-fund-balance-cell > strong {
  color: var(--text-primary);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#view[data-view="finance"] .real-fund-flow-account-desktop,
#view[data-view="finance"] .real-fund-flow-source-cell {
  min-width: 0;
  display: grid;
  gap: 3px;
}

#view[data-view="finance"] .real-fund-flow-account-desktop strong,
#view[data-view="finance"] .real-fund-flow-source-cell strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view[data-view="finance"] .real-fund-flow-account-desktop small,
#view[data-view="finance"] .real-fund-flow-source-cell > span {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view[data-view="finance"] .real-fund-flow-type-chip {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  color: #31506f;
  background: #f2f6fa;
  border: 1px solid #dbe5ef;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

@media (min-width: 781px) {
  #view[data-view="finance"] .finance-command-center {
    margin-bottom: 10px;
    padding: 10px;
  }

  #view[data-view="finance"] .finance-command-metrics > div {
    min-height: 78px;
    align-content: center;
    padding: 11px 13px;
  }

  #view[data-view="finance"] .finance-tab-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 12px;
  }

  #view[data-view="finance"] .finance-page-panel {
    gap: 12px;
  }

  #view[data-view="finance"] .finance-filter-bar:not(.fund-balance-filter) {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(132px, 160px)) auto;
    gap: 8px;
    margin: 0;
    padding: 10px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }

  #view[data-view="finance"] .real-fund-filter-form.finance-filter-bar {
    grid-template-columns: minmax(260px, 1fr) 168px minmax(230px, .85fr) auto;
  }

  #view[data-view="finance"] .ledger-card-table thead th {
    padding-top: 11px;
    padding-bottom: 11px;
    background: #f7f9fc;
  }

  #view[data-view="finance"] .ledger-card-table tbody td {
    padding-top: 12px;
    padding-bottom: 12px;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] {
    padding: 6px 8px;
  }

  #view[data-view="finance"] .finance-command-center {
    margin-bottom: 5px;
    padding: 5px;
    border-radius: var(--radius-md);
  }

  #view[data-view="finance"] .finance-command-metrics {
    gap: 4px;
  }

  #view[data-view="finance"] .finance-command-metrics > div {
    min-height: 47px;
    gap: 1px;
    padding: 5px 7px;
  }

  #view[data-view="finance"] .finance-command-metrics strong {
    font-size: 13.5px;
  }

  #view[data-view="finance"] .finance-tab-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 5px;
  }

  #view[data-view="finance"] .finance-tab-btn {
    min-height: 42px;
    flex-direction: row;
    gap: 5px;
    padding: 5px 4px;
    border-radius: var(--radius-md);
  }

  #view[data-view="finance"] .finance-tab-btn span {
    font-size: 10.5px;
  }

  #view[data-view="finance"] .finance-page-panel {
    gap: 7px;
    padding: 8px;
    border-radius: var(--radius-lg);
  }

  #view[data-view="finance"] .finance-panel-toolbar {
    gap: 7px;
  }

  #view[data-view="finance"] .finance-panel-heading h2 {
    font-size: 16px;
  }

  #view[data-view="finance"] .finance-panel-heading .compact {
    display: -webkit-box;
    margin-top: 2px;
    overflow: hidden;
    font-size: 10.5px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #view[data-view="finance"] .finance-entry-actions {
    gap: 5px;
  }

  #view[data-view="finance"] .finance-entry-button {
    min-height: 38px;
    grid-template-columns: 17px minmax(0, auto) 13px;
    gap: 6px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    box-shadow: 0 3px 9px rgba(20, 93, 165, .15);
    font-size: 12px;
  }

  #view[data-view="finance"] .finance-entry-button svg {
    width: 16px;
    height: 16px;
  }

  #view[data-view="finance"] .fund-account-grid {
    gap: 6px;
    padding-bottom: 1px;
  }

  #view[data-view="finance"] .fund-account-card {
    flex-basis: min(69vw, 220px);
    min-height: 82px;
    gap: 2px;
    padding: 8px 9px;
  }

  #view[data-view="finance"] .fund-account-card strong {
    font-size: 13px;
  }

  #view[data-view="finance"] .fund-account-card b {
    font-size: 17px;
  }

  #view[data-view="finance"] .fund-account-card :where(span, small) {
    font-size: 10px;
  }

  #view[data-view="finance"] .finance-filter-toggle {
    width: 100%;
    min-height: 39px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 16px;
    gap: 7px;
    align-items: center;
    padding: 0 10px;
    color: var(--text-primary);
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    cursor: pointer;
  }

  #view[data-view="finance"] .finance-filter-toggle-label {
    min-width: 0;
    display: inline-flex;
    gap: 7px;
    align-items: center;
    font-size: 12px;
  }

  #view[data-view="finance"] .finance-filter-toggle-label svg,
  #view[data-view="finance"] .finance-filter-toggle-chevron {
    width: 15px;
    height: 15px;
    color: var(--brand);
  }

  #view[data-view="finance"] .finance-filter-toggle-meta {
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 650;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-filter-toggle-chevron {
    transition: transform .16s ease;
  }

  #view[data-view="finance"] .finance-filter-toggle.is-expanded .finance-filter-toggle-chevron {
    transform: rotate(180deg);
  }

  #view[data-view="finance"] .finance-filter-bar,
  #view[data-view="finance"] .fund-balance-filter {
    display: none;
  }

  #view[data-view="finance"] .finance-filter-bar.is-expanded,
  #view[data-view="finance"] .fund-balance-filter.is-expanded {
    display: grid;
    padding: 7px;
  }

  #view[data-view="finance"] .ledger-card-table tbody {
    gap: 6px;
  }

  #view[data-view="finance"] .ledger-card-table tr {
    gap: 6px;
    padding: 8px;
    border-radius: var(--radius-md);
  }

  #view[data-view="finance"] .ledger-card-table .mobile-card-head {
    gap: 7px;
  }

  #view[data-view="finance"] .ledger-card-table .mobile-card-head strong {
    font-size: 13.5px;
    line-height: 1.25;
  }

  #view[data-view="finance"] .ledger-card-table .mobile-card-head small {
    font-size: 10px;
  }

  #view[data-view="finance"] .ledger-card-table .status-chip {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 10px;
  }

  #view[data-view="finance"] .ledger-card-table .mobile-card-grid {
    gap: 4px;
  }

  #view[data-view="finance"] .ledger-card-table .mobile-card-field {
    min-height: 41px;
    padding: 5px 7px;
  }

  #view[data-view="finance"] .ledger-card-table .mobile-card-field span {
    font-size: 9.5px;
  }

  #view[data-view="finance"] .ledger-card-table .mobile-card-field strong {
    font-size: 11.5px;
    line-height: 1.25;
  }

  /* Finance mobile records use one continuous surface instead of nested field tiles. */
  #view[data-view="finance"] .finance-ledger-summary-card,
  #view[data-view="finance"] .finance-flow-card {
    gap: 0;
  }

  #view[data-view="finance"] .finance-ledger-summary-head,
  #view[data-view="finance"] .finance-flow-card-head {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    padding: 0 1px 8px;
  }

  #view[data-view="finance"] :where(.finance-ledger-summary-head, .finance-flow-card-head) > div {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  #view[data-view="finance"] .finance-ledger-summary-head small,
  #view[data-view="finance"] .finance-flow-card-head small {
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 650;
    line-height: 1.3;
  }

  #view[data-view="finance"] .finance-ledger-summary-head strong,
  #view[data-view="finance"] .finance-flow-card-head strong {
    min-width: 0;
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #view[data-view="finance"] .finance-ledger-summary-head > .status-chip,
  #view[data-view="finance"] .finance-flow-card-head > .status-chip {
    max-width: 112px;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-ledger-total-row {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 8px 1px;
    border-top: 1px solid var(--border);
  }

  #view[data-view="finance"] .finance-ledger-total-row > div {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  #view[data-view="finance"] .finance-ledger-total-row span,
  #view[data-view="finance"] .finance-ledger-balance-band span,
  #view[data-view="finance"] .finance-flow-amount-row span,
  #view[data-view="finance"] .finance-flow-fact span,
  #view[data-view="finance"] .finance-flow-note span {
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 650;
    line-height: 1.25;
  }

  #view[data-view="finance"] .finance-ledger-total-row small {
    color: var(--text-secondary);
    font-size: 10.5px;
    line-height: 1.25;
  }

  #view[data-view="finance"] .finance-ledger-total-row > strong {
    min-width: 0;
    color: var(--text-primary);
    font-size: 19px;
    line-height: 1.1;
    text-align: right;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-ledger-balance-band,
  #view[data-view="finance"] .finance-flow-amount-row,
  #view[data-view="finance"] .finance-flow-facts {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="finance"] :where(.finance-ledger-balance-band, .finance-flow-amount-row, .finance-flow-facts) > div {
    min-width: 0;
    display: grid;
    gap: 3px;
    align-content: center;
    padding: 7px 8px 7px 1px;
  }

  #view[data-view="finance"] :where(.finance-ledger-balance-band, .finance-flow-amount-row, .finance-flow-facts) > div + div {
    padding-right: 1px;
    padding-left: 9px;
    border-left: 1px solid var(--border);
  }

  #view[data-view="finance"] .finance-ledger-balance-band strong,
  #view[data-view="finance"] .finance-flow-amount-row strong,
  #view[data-view="finance"] .finance-flow-fact strong,
  #view[data-view="finance"] .finance-flow-source {
    min-width: 0;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  #view[data-view="finance"] .finance-flow-amount-row {
    border-bottom: 0;
  }

  #view[data-view="finance"] .finance-flow-amount-row strong {
    font-size: 16px;
    line-height: 1.15;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-flow-source :where(button, a) {
    max-width: 100%;
  }

  #view[data-view="finance"] .finance-ledger-recent-row,
  #view[data-view="finance"] .finance-flow-card-foot {
    min-width: 0;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 7px 1px 0;
    color: var(--text-secondary);
    font-size: 10.5px;
    line-height: 1.3;
  }

  #view[data-view="finance"] :where(.finance-ledger-recent-row, .finance-flow-card-foot) span {
    min-width: 0;
    display: inline-flex;
    gap: 5px;
    align-items: center;
  }

  #view[data-view="finance"] :where(.finance-ledger-recent-row, .finance-flow-card-foot) svg {
    width: 13px;
    height: 13px;
  }

  #view[data-view="finance"] :where(.finance-ledger-recent-row, .finance-flow-card-foot) time {
    min-width: 0;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-flow-note {
    min-width: 0;
    display: grid;
    gap: 2px;
    padding: 7px 1px;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="finance"] .finance-flow-note strong {
    color: var(--text-primary);
    font-size: 11.5px;
    font-weight: 650;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  #view[data-view="finance"] .finance-ledger-panel .mobile-action-cell {
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }

  #view[data-view="finance"] .fund-account-card-head {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px;
    align-items: center;
  }

  #view[data-view="finance"] .fund-account-card-head > span {
    width: fit-content;
    padding: 2px 6px;
    background: rgba(255, 255, 255, .72);
    border: 1px solid currentColor;
    border-radius: 999px;
    line-height: 1.2;
  }

  #view[data-view="finance"] .fund-account-card-head > strong {
    display: block;
    overflow: hidden;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .fund-account-card-balance {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 1px;
    align-items: end;
  }

  #view[data-view="finance"] .fund-account-card-balance > b {
    text-align: right;
    white-space: nowrap;
  }

  #view[data-view="finance"] .fund-account-card-meta {
    gap: 6px;
    padding-top: 5px;
    border-top: 1px solid rgba(148, 163, 184, .25);
  }

  #view[data-view="finance"] .fund-account-card-meta :where(span, time) {
    min-width: 0;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 9.5px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .ledger-action-row {
    gap: 4px;
  }

  #view[data-view="finance"] .ledger-action-row .small-btn {
    min-height: 34px;
    padding: 5px 6px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  #view[data-view="finance"] .finance-tab-btn {
    gap: 4px;
  }

  #view[data-view="finance"] .finance-tab-btn span {
    overflow: visible;
    font-size: 9.5px;
    text-overflow: clip;
  }
}

/* Customer and supplier ledger details share one scanning hierarchy. */
.finance-detail-modal .ledger-detail-heading {
  min-width: 0;
}

.finance-detail-modal .ledger-detail-title-row {
  min-width: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.finance-detail-modal .ledger-detail-title-row h2 {
  min-width: 0;
}

.finance-detail-modal .ledger-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.finance-detail-modal .ledger-detail-metric {
  min-width: 0;
  min-height: 94px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  padding: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.finance-detail-modal .ledger-detail-metric.is-primary {
  background: #f4f8ff;
  border-color: #cfe0f6;
}

.finance-detail-modal .ledger-detail-metric.is-danger {
  background: #fff5f4;
  border-color: #efc9c5;
}

.finance-detail-modal .ledger-detail-metric.is-corp {
  background: #f1fbf6;
  border-color: #c8e9d8;
}

.finance-detail-modal .ledger-detail-metric.is-card {
  background: #f4f8ff;
  border-color: #cfe0f6;
}

.finance-detail-modal .ledger-detail-metric-label {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.finance-detail-modal .ledger-detail-metric-label svg {
  width: 18px;
  height: 18px;
}

.finance-detail-modal .ledger-detail-metric > strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-detail-modal .ledger-detail-metric.is-danger > strong {
  color: var(--danger);
}

.finance-detail-modal .ledger-detail-metric > small {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-detail-modal .ledger-flow-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  color: var(--text-primary);
}

.finance-detail-modal .ledger-flow-section-head > div {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.finance-detail-modal .ledger-flow-section-head svg {
  width: 16px;
  height: 16px;
  color: var(--brand);
}

.finance-detail-modal .ledger-flow-section-head > span {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.customer-ledger-overview {
  display: grid;
  gap: 7px;
}

.customer-ledger-balance-hero {
  display: grid;
  grid-template-columns: minmax(230px, 1.2fr) minmax(300px, 1.45fr) minmax(180px, .8fr);
  min-height: 70px;
  overflow: hidden;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.customer-ledger-balance-main,
.customer-ledger-balance-splits,
.customer-ledger-balance-status {
  min-width: 0;
  padding: 9px 12px;
}

.customer-ledger-balance-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "label amount" "hint amount";
  gap: 2px 12px;
  align-items: center;
  background: #f4f8ff;
  border-right: 1px solid var(--border);
}

.customer-ledger-balance-main > span {
  grid-area: label;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.customer-ledger-balance-main > strong {
  grid-area: amount;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-ledger-balance-main > small {
  grid-area: hint;
  color: var(--text-secondary);
  font-size: 9px;
}

.customer-ledger-balance-splits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-right: 1px solid var(--border);
}

.customer-ledger-balance-splits > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 0 10px;
}

.customer-ledger-balance-splits > div + div {
  border-left: 1px solid var(--border);
}

.customer-ledger-balance-splits span,
.customer-ledger-balance-status span,
.customer-ledger-balance-status small {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-ledger-balance-splits strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-ledger-balance-status {
  display: grid;
  gap: 4px;
  align-content: center;
}

.customer-ledger-balance-status span {
  color: var(--text-primary);
  font-weight: 700;
}

.customer-ledger-range-panel {
  display: grid;
  gap: 7px;
  padding: 8px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.customer-ledger-scope-level {
  min-width: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.customer-ledger-scope-label {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.customer-ledger-scope-rail {
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: #a9b9cd transparent;
  scrollbar-width: thin;
}

.customer-ledger-scope-rail::-webkit-scrollbar {
  height: 5px;
}

.customer-ledger-scope-rail::-webkit-scrollbar-thumb {
  background: #a9b9cd;
  border-radius: 999px;
}

.customer-ledger-scope-primary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: visible;
}

.customer-ledger-scope-button {
  min-width: 0;
  color: var(--text-primary);
  background-color: var(--surface-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.customer-ledger-scope-button:hover {
  background: #f6f9fd;
  border-color: #9ebce3;
}

.customer-ledger-scope-button:focus-visible {
  outline: 2px solid rgba(31, 102, 179, .25);
  outline-offset: 1px;
}

.customer-ledger-scope-button.is-active {
  color: #174f91;
  background: #eaf3ff;
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(31, 102, 179, .12);
}

.customer-ledger-scope-button.is-active .danger-text {
  color: #b42318;
}

.customer-ledger-scope-button.is-primary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 7px 10px;
  text-align: left;
}

.customer-ledger-scope-button.is-primary > span {
  min-width: 0;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-ledger-scope-button.is-primary svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}

.customer-ledger-scope-button.is-primary > strong,
.customer-ledger-scope-button.is-compact > strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.customer-ledger-scope-button.is-primary > strong {
  font-size: 14px;
}

.customer-ledger-scope-button.is-primary > small,
.customer-ledger-scope-button.is-compact > small {
  color: var(--text-secondary);
  font-size: 9px;
  white-space: nowrap;
}

.customer-ledger-scope-button.is-compact {
  flex: 0 0 auto;
  min-width: 178px;
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label amount" "label meta";
  gap: 1px 9px;
  align-items: center;
  padding: 5px 9px;
  text-align: left;
}

.customer-ledger-scope-button.is-compact > span {
  grid-area: label;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-ledger-scope-button.is-compact > strong {
  grid-area: amount;
  font-size: 11px;
  text-align: right;
}

.customer-ledger-scope-button.is-compact > small {
  grid-area: meta;
  text-align: right;
}

.customer-ledger-scope-button.is-counterparty {
  min-width: 206px;
}

.customer-ledger-range-panel .customer-ledger-account-note {
  margin: 0;
  padding-left: 72px;
  font-size: 10px;
}

.customer-ledger-flow-head {
  min-height: 32px;
  margin-top: 1px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.customer-ledger-flow-head > div:first-child {
  min-width: 0;
}

.customer-ledger-flow-head > div:first-child > strong,
.customer-ledger-flow-head > div:first-child > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-ledger-flow-head > div:first-child > span {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
}

.customer-ledger-range-total {
  display: flex;
  gap: 7px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

.customer-ledger-range-total small {
  color: var(--text-secondary);
  font-size: 10px;
}

.customer-ledger-range-total strong {
  color: var(--text-primary);
  font-size: 14px;
}

.ledger-detail-mobile-card {
  display: none;
}

@media (max-width: 780px) {
  .finance-detail-modal .modal-header {
    padding: 10px 12px;
  }

  .finance-detail-modal .modal-header .eyebrow {
    margin-bottom: 2px;
    font-size: 9.5px;
  }

  .finance-detail-modal .ledger-detail-title-row {
    gap: 7px;
    align-items: flex-start;
  }

  .finance-detail-modal .ledger-detail-title-row h2 {
    flex: 1 1 auto;
    font-size: 17px;
  }

  .finance-detail-modal .ledger-detail-title-row .status-chip {
    flex: 0 0 auto;
    min-height: 23px;
    padding: 3px 7px;
    font-size: 9.5px;
  }

  .finance-detail-modal .modal-body {
    gap: 7px;
    padding: 8px;
  }

  .finance-detail-modal .ledger-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .finance-detail-modal .ledger-detail-metric {
    min-height: 67px;
    gap: 2px;
    padding: 7px 8px;
    border-radius: 7px;
  }

  .finance-detail-modal .ledger-detail-metric-label {
    font-size: 9.5px;
  }

  .finance-detail-modal .ledger-detail-metric-label svg {
    width: 14px;
    height: 14px;
  }

  .finance-detail-modal .ledger-detail-metric > strong {
    font-size: 15px;
  }

  .finance-detail-modal .ledger-detail-metric > small {
    font-size: 9px;
  }

  .finance-detail-modal .ledger-company-summary {
    gap: 5px;
    padding: 7px;
  }

  .finance-detail-modal .ledger-company-summary-head {
    min-height: 24px;
  }

  .finance-detail-modal .ledger-company-balance-list {
    display: flex;
    grid-template-columns: none;
    gap: 5px;
    padding-bottom: 1px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .finance-detail-modal .ledger-company-balance-list::-webkit-scrollbar {
    display: none;
  }

  .finance-detail-modal .ledger-company-balance-item {
    flex: 0 0 min(72vw, 255px);
    min-height: 58px;
    gap: 8px;
    padding: 6px 7px;
    scroll-snap-align: start;
  }

  .finance-detail-modal .ledger-company-balance-item strong {
    font-size: 11px;
  }

  .finance-detail-modal .ledger-company-balance-item span {
    font-size: 9px;
  }

  .finance-detail-modal .ledger-company-balance-item b {
    font-size: 12px;
  }

  .finance-detail-modal .ledger-flow-section-head {
    min-height: 30px;
    padding: 0 4px;
  }

  .finance-detail-modal .ledger-flow-table tbody {
    gap: 6px;
  }

  .finance-detail-modal .ledger-flow-table tr {
    display: block;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .finance-detail-modal .ledger-flow-table tr > td {
    display: none;
  }

  .finance-detail-modal .ledger-flow-table tr > td:first-child {
    display: block;
    padding: 0;
    background: transparent;
    border: 0;
  }

  .finance-detail-modal .ledger-flow-table tr > td:first-child::before,
  .finance-detail-modal .ledger-flow-table tr > td:first-child > .ledger-entry-date,
  .finance-detail-modal .ledger-flow-table tr > td:first-child > .ledger-entry-type-chip {
    display: none;
  }

  .finance-detail-modal .ledger-detail-mobile-card {
    display: grid;
    gap: 6px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 7px rgba(15, 23, 42, .035);
  }

  .finance-detail-modal .ledger-detail-mobile-card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }

  .finance-detail-modal .ledger-detail-mobile-card-head > div:first-child {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
  }

  .finance-detail-modal .ledger-detail-mobile-card-head time {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 800;
  }

  .finance-detail-modal .ledger-detail-mobile-amount {
    display: grid;
    justify-items: end;
    gap: 1px;
    font-variant-numeric: tabular-nums;
  }

  .finance-detail-modal .ledger-detail-mobile-amount > span,
  .finance-detail-modal .ledger-detail-mobile-amount > small {
    color: var(--text-secondary);
    font-size: 9px;
  }

  .finance-detail-modal .ledger-detail-mobile-amount > strong {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.2;
  }

  .finance-detail-modal .ledger-detail-mobile-card.positive .ledger-detail-mobile-amount > strong {
    color: var(--success);
  }

  .finance-detail-modal .ledger-detail-mobile-card.negative .ledger-detail-mobile-amount > strong,
  .finance-detail-modal .ledger-detail-mobile-amount > small.negative {
    color: var(--danger);
  }

  .finance-detail-modal .ledger-detail-mobile-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .finance-detail-modal .ledger-detail-mobile-fact {
    min-width: 0;
    min-height: 52px;
    display: grid;
    align-content: start;
    gap: 2px;
    padding: 6px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 7px;
  }

  .finance-detail-modal .ledger-detail-mobile-fact.is-corp {
    background: #f1fbf6;
    border-color: #c8e9d8;
  }

  .finance-detail-modal .ledger-detail-mobile-fact.is-card {
    background: #f4f8ff;
    border-color: #cfe0f6;
  }

  .finance-detail-modal .ledger-detail-mobile-fact.wide {
    grid-column: 1 / -1;
  }

  .finance-detail-modal .ledger-detail-mobile-fact > span {
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: 700;
  }

  .finance-detail-modal .ledger-detail-mobile-fact > strong {
    min-width: 0;
    display: flex;
    gap: 4px;
    align-items: center;
    color: var(--text-primary);
    font-size: 11px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .finance-detail-modal .ledger-detail-mobile-fact > strong > svg {
    flex: 0 0 auto;
    width: 13px;
    height: 13px;
  }

  .finance-detail-modal .ledger-detail-mobile-fact .small-btn {
    width: fit-content;
    min-height: 27px;
    padding: 4px 7px;
    font-size: 10px;
  }

  .finance-detail-modal .ledger-detail-mobile-fact > small {
    color: var(--text-secondary);
    font-size: 9px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .finance-detail-modal .ledger-detail-mobile-card-foot {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 9px;
  }

  .finance-detail-modal .ledger-detail-mobile-card-foot > span {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    color: var(--text-primary);
    font-weight: 700;
  }

  .finance-detail-modal .ledger-detail-mobile-card-foot svg {
    width: 12px;
    height: 12px;
  }

  .customer-ledger-balance-hero {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    min-height: 78px;
  }

  .customer-ledger-balance-main,
  .customer-ledger-balance-splits,
  .customer-ledger-balance-status {
    padding: 7px 8px;
  }

  .customer-ledger-balance-main {
    grid-template-columns: 1fr;
    grid-template-areas: "label" "amount";
    gap: 2px;
  }

  .customer-ledger-balance-main > strong {
    font-size: 19px;
    text-align: left;
  }

  .customer-ledger-balance-main > small {
    display: none;
  }

  .customer-ledger-balance-splits {
    gap: 4px;
    padding-inline: 0;
    border-right: 0;
  }

  .customer-ledger-balance-splits > div {
    gap: 2px;
    padding: 0 7px;
  }

  .customer-ledger-balance-splits strong {
    font-size: 12px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .customer-ledger-balance-status {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    padding-block: 5px;
    border-top: 1px solid var(--border);
  }

  .customer-ledger-balance-status small {
    text-align: right;
  }

  .customer-ledger-range-panel {
    gap: 5px;
    padding: 7px 8px;
  }

  .customer-ledger-scope-primary {
    gap: 4px;
  }

  .customer-ledger-scope-button.is-primary {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 2px;
    min-height: 48px;
    padding: 5px 6px;
    text-align: center;
  }

  .customer-ledger-scope-button.is-primary > span {
    justify-content: center;
    font-size: 9px;
  }

  .customer-ledger-scope-button.is-primary > strong {
    font-size: 11px;
  }

  .customer-ledger-scope-button.is-primary > small,
  .customer-ledger-scope-button.is-primary svg {
    display: none;
  }

  .customer-ledger-scope-level {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .customer-ledger-scope-label {
    font-size: 9px;
  }

  .customer-ledger-scope-rail {
    padding-bottom: 3px;
  }

  .customer-ledger-scope-button.is-compact {
    min-width: 156px;
    min-height: 38px;
    padding: 4px 7px;
  }

  .customer-ledger-scope-button.is-counterparty {
    min-width: 180px;
  }

  .customer-ledger-range-panel .customer-ledger-account-note {
    padding-left: 0;
    font-size: 9px;
  }

  .customer-ledger-flow-head {
    gap: 8px;
    min-height: 29px;
    padding-top: 5px;
  }

  .customer-ledger-flow-head > div:first-child {
    gap: 4px;
  }

  .customer-ledger-flow-head > div:first-child > span {
    display: none;
  }

  .customer-ledger-range-total {
    flex: 0 0 auto;
    gap: 4px;
  }

  .customer-ledger-range-total strong {
    font-size: 12px;
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-card {
    gap: 5px;
    padding: 7px 8px;
    box-shadow: none;
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-facts {
    gap: 0;
    border-bottom: 1px solid var(--border);
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-fact {
    min-height: 0;
    gap: 2px;
    padding: 6px 8px 6px 0;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-fact:nth-child(even):not(.wide) {
    padding-right: 0;
    padding-left: 8px;
    border-left: 1px solid var(--border);
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-fact.is-card,
  .customer-ledger-detail-modal .ledger-detail-mobile-fact.is-corp {
    background: transparent;
    border-color: var(--border);
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-fact.wide {
    padding-right: 0;
    border-top: 1px solid var(--border);
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-card-foot {
    flex-wrap: wrap;
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-card-foot > time {
    margin-left: auto;
  }

  .customer-ledger-detail-modal .ledger-detail-mobile-card-foot .ledger-company-assignment-button.is-mobile {
    flex: 1 0 100%;
    width: 100%;
    min-height: 32px;
    margin: 2px 0 0;
    justify-content: center;
  }

  .finance-detail-modal .ledger-pagination {
    margin-top: 0;
    padding-top: 7px;
  }
}

@media (max-width: 360px) {
  .customer-ledger-balance-hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .customer-ledger-balance-main {
    grid-column: 1 / -1;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "label amount";
    border-right: 0;
  }

  .customer-ledger-balance-main > strong {
    text-align: right;
  }

  .customer-ledger-balance-splits {
    grid-column: 1 / -1;
    min-height: 42px;
    border-top: 1px solid var(--border);
  }

  .customer-ledger-balance-splits strong {
    font-size: 11px;
    white-space: nowrap;
  }
}

/* Profit calculator: compact, calculation-first workspace. */
#view[data-view="profitCalculator"] .profit-calc-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(115deg, #f8fbff 0%, #fff 52%, #f2fbf6 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

#view[data-view="profitCalculator"] .profit-calc-hero h2 {
  margin-bottom: 2px;
}

#view[data-view="profitCalculator"] .profit-calc-hero-reset {
  flex: 0 0 auto;
  min-height: 38px;
  color: var(--brand-active);
  background: #fff;
  border-color: #bfd2ec;
}

#view[data-view="profitCalculator"] .profit-calc-shell {
  grid-template-columns: minmax(0, 1fr) minmax(310px, 350px);
  gap: var(--space-4);
}

#view[data-view="profitCalculator"] .profit-calc-input-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

#view[data-view="profitCalculator"] .profit-calc-section {
  gap: var(--space-3);
  padding: var(--space-4);
  border-color: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

#view[data-view="profitCalculator"] .profit-calc-section-head {
  align-items: center;
  padding-bottom: var(--space-2);
}

#view[data-view="profitCalculator"] .profit-calc-section-head > div {
  gap: var(--space-2);
}

#view[data-view="profitCalculator"] .profit-calc-section-head h3 {
  font-size: 16px;
}

#view[data-view="profitCalculator"] .profit-calc-section-head > span {
  max-width: none;
  font-size: 12px;
}

#view[data-view="profitCalculator"] .profit-calc-entry-grid {
  display: grid;
  gap: var(--space-3);
}

#view[data-view="profitCalculator"] .profit-calc-entry-grid-primary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#view[data-view="profitCalculator"] .profit-calc-entry-grid-costs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#view[data-view="profitCalculator"] .profit-calc-entry {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

#view[data-view="profitCalculator"] .profit-calc-entry-head {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#view[data-view="profitCalculator"] .profit-calc-entry-head > div {
  min-width: 0;
  display: grid;
  gap: 1px;
}

#view[data-view="profitCalculator"] .profit-calc-entry-head h4 {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
}

#view[data-view="profitCalculator"] .profit-calc-entry-head > div > span {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.35;
}

#view[data-view="profitCalculator"] .profit-calc-entry .order-section-icon {
  width: 28px;
  height: 28px;
}

#view[data-view="profitCalculator"] .profit-calc-entry .order-section-icon svg {
  width: 15px;
  height: 15px;
}

#view[data-view="profitCalculator"] .settlement-channel-picker {
  gap: 7px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

#view[data-view="profitCalculator"] .settlement-channel-picker[data-selected-channel] {
  background: transparent;
  border-color: transparent;
}

#view[data-view="profitCalculator"] .settlement-channel-picker-head {
  display: none;
}

#view[data-view="profitCalculator"] .settlement-channel-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

#view[data-view="profitCalculator"] .settlement-channel-option {
  min-height: 34px;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 5px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

#view[data-view="profitCalculator"] .settlement-channel-option:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
}

#view[data-view="profitCalculator"] .settlement-channel-option-icon {
  width: 16px;
  height: 16px;
  background: transparent;
}

#view[data-view="profitCalculator"] .settlement-channel-option-icon svg {
  width: 14px;
  height: 14px;
}

#view[data-view="profitCalculator"] .settlement-channel-option small,
#view[data-view="profitCalculator"] .settlement-channel-selected {
  display: none;
}

#view[data-view="profitCalculator"] .settlement-channel-option strong {
  font-size: 12px;
}

#view[data-view="profitCalculator"] .settlement-channel-detail-slot {
  min-height: 0;
  gap: 0;
}

#view[data-view="profitCalculator"] .profit-calc-money-grid {
  display: contents;
}

#view[data-view="profitCalculator"] .profit-calc-money-card {
  gap: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

#view[data-view="profitCalculator"] .profit-calc-money-fields {
  display: block;
}

#view[data-view="profitCalculator"] .profit-calc-money-fields .field {
  gap: 4px;
}

#view[data-view="profitCalculator"] .profit-calc-money-fields .field > span {
  color: var(--text-secondary);
  font-size: 11px;
}

#view[data-view="profitCalculator"] .profit-calc-money-fields input {
  min-height: 42px;
  padding: 8px 10px;
  color: var(--text-primary);
  background: #fff;
  border-color: #cbd9e8;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#view[data-view="profitCalculator"] .profit-calc-money-fields input::placeholder {
  color: #9aa9bb;
  font-weight: 600;
}

#view[data-view="profitCalculator"] .profit-calc-section-tools {
  display: flex;
  justify-content: flex-start;
  gap: var(--space-2);
}

#view[data-view="profitCalculator"] #profit-calc-other-list {
  gap: var(--space-2);
}

#view[data-view="profitCalculator"] .profit-calc-other-row {
  grid-template-columns: minmax(250px, 1fr) minmax(210px, .8fr) minmax(180px, .7fr);
  gap: var(--space-2);
  align-items: end;
  padding: var(--space-3);
  background: var(--surface-subtle);
  border-color: var(--border);
  border-radius: var(--radius-md);
}

#view[data-view="profitCalculator"] .profit-calc-other-head {
  grid-template-columns: minmax(92px, .7fr) minmax(120px, 1fr) auto;
  gap: var(--space-2);
}

#view[data-view="profitCalculator"] .profit-calc-other-head .small-btn {
  width: 36px;
  min-width: 36px;
  padding-inline: 0;
}

#view[data-view="profitCalculator"] .profit-calc-other-head .small-btn span {
  display: none;
}

#view[data-view="profitCalculator"] .profit-calc-actions {
  margin-top: -2px;
}

#view[data-view="profitCalculator"] .profit-calc-result-panel {
  top: 76px;
  gap: 0;
  padding: 0;
  overflow: visible;
}

#view[data-view="profitCalculator"] .profit-calc-result-main {
  position: relative;
  padding: var(--space-5);
  background: linear-gradient(145deg, #f2f7ff 0%, #fff 58%, #effaf4 100%);
  border-color: #bed2eb;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

#view[data-view="profitCalculator"] .profit-calc-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

#view[data-view="profitCalculator"] .profit-calc-result-head h2 {
  margin: 2px 0 0;
  font-size: 17px;
}

#view[data-view="profitCalculator"] .profit-calc-tax-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  color: #0b6b45;
  background: #e9f8ef;
  border: 1px solid #b9e4cb;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

#view[data-view="profitCalculator"] .profit-calc-tax-status svg {
  width: 13px;
  height: 13px;
}

#view[data-view="profitCalculator"] .profit-calc-result-main .summary-metric {
  display: grid;
  gap: 3px;
  margin: var(--space-4) 0;
}

#view[data-view="profitCalculator"] .profit-calc-result-main .summary-metric strong {
  color: var(--brand-active);
  font-size: clamp(28px, 3vw, 38px);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

#view[data-view="profitCalculator"] .profit-calc-result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: 0;
}

#view[data-view="profitCalculator"] .profit-calc-result-grid > div {
  gap: 2px;
  padding: var(--space-2);
  background: rgba(255, 255, 255, .78);
  border-color: #dbe6f2;
  border-radius: var(--radius-sm);
}

#view[data-view="profitCalculator"] .profit-calc-result-grid strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#view[data-view="profitCalculator"] .profit-calc-result-note {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: var(--space-3) 0 0;
  color: var(--text-secondary);
  font-size: 11px;
}

#view[data-view="profitCalculator"] .profit-calc-result-note svg {
  width: 14px;
  height: 14px;
}

@media (max-width: 1280px) {
  #view[data-view="profitCalculator"] .profit-calc-entry-grid-costs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #view[data-view="profitCalculator"] .profit-calc-packing-entry {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1120px) {
  #view[data-view="profitCalculator"] .profit-calc-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  #view[data-view="profitCalculator"] .profit-calc-result-panel {
    order: -1;
    position: static;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-main {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(300px, 1.2fr);
    gap: var(--space-3) var(--space-4);
    align-items: center;
    padding: var(--space-4);
  }

  #view[data-view="profitCalculator"] .profit-calc-result-head,
  #view[data-view="profitCalculator"] .profit-calc-result-main .summary-metric {
    grid-column: 1;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-grid {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-note {
    display: none;
  }
}

@media (max-width: 700px) {
  #view[data-view="profitCalculator"] .profit-calc-hero {
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    padding: var(--space-3);
  }

  #view[data-view="profitCalculator"] .profit-calc-hero .eyebrow {
    display: none;
  }

  #view[data-view="profitCalculator"] .profit-calc-hero h2 {
    font-size: 19px;
  }

  #view[data-view="profitCalculator"] .profit-calc-hero .muted {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.35;
  }

  #view[data-view="profitCalculator"] .profit-calc-hero-reset {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 11px;
  }

  #view[data-view="profitCalculator"] .profit-calc-shell,
  #view[data-view="profitCalculator"] .profit-calc-input-stack {
    gap: var(--space-2);
  }

  #view[data-view="profitCalculator"] .profit-calc-result-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  #view[data-view="profitCalculator"] .profit-calc-result-head {
    display: block;
    grid-column: 1;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-head h2 {
    font-size: 13px;
  }

  #view[data-view="profitCalculator"] .profit-calc-tax-status {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
  }

  #view[data-view="profitCalculator"] .profit-calc-result-main .summary-metric {
    grid-column: 1 / -1;
    margin: 2px 0 0;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-main .summary-metric span {
    display: none;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-main .summary-metric strong {
    font-size: 27px;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-grid {
    grid-column: 1 / -1;
    grid-row: auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-grid > div {
    padding: 6px;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-grid span {
    font-size: 9px;
  }

  #view[data-view="profitCalculator"] .profit-calc-result-grid strong {
    font-size: 10px;
  }

  #view[data-view="profitCalculator"] .profit-calc-section {
    gap: var(--space-2);
    padding: var(--space-3);
  }

  #view[data-view="profitCalculator"] .profit-calc-section-head {
    padding-bottom: 6px;
  }

  #view[data-view="profitCalculator"] .profit-calc-section-head h3 {
    font-size: 14px;
  }

  #view[data-view="profitCalculator"] .profit-calc-section-head > span {
    display: none;
  }

  #view[data-view="profitCalculator"] .profit-calc-entry-grid,
  #view[data-view="profitCalculator"] .profit-calc-entry-grid-costs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  #view[data-view="profitCalculator"] .profit-calc-packing-entry {
    grid-column: auto;
  }

  #view[data-view="profitCalculator"] .profit-calc-entry {
    gap: 6px;
    padding: 8px;
  }

  #view[data-view="profitCalculator"] .profit-calc-entry-head > .order-section-icon {
    display: none;
  }

  #view[data-view="profitCalculator"] .profit-calc-entry-head h4 {
    font-size: 13px;
  }

  #view[data-view="profitCalculator"] .profit-calc-entry-head > div > span,
  #view[data-view="profitCalculator"] .profit-calc-money-fields .field > span {
    font-size: 9px;
  }

  #view[data-view="profitCalculator"] .settlement-channel-option {
    min-height: 30px;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    padding: 4px;
  }

  #view[data-view="profitCalculator"] .settlement-channel-option-icon {
    display: none;
  }

  #view[data-view="profitCalculator"] .settlement-channel-option strong {
    font-size: 10px;
  }

  #view[data-view="profitCalculator"] .profit-calc-money-fields input {
    min-height: 38px;
    padding: 7px 8px;
    font-size: 15px;
  }

  #view[data-view="profitCalculator"] .profit-calc-other-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 8px;
  }

  #view[data-view="profitCalculator"] .profit-calc-other-head {
    grid-template-columns: minmax(84px, .7fr) minmax(110px, 1fr) auto;
    gap: 6px;
  }

  #view[data-view="profitCalculator"] .profit-calc-other-row .settlement-channel-picker {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
    gap: 6px;
  }

  #view[data-view="profitCalculator"] .profit-calc-other-row .settlement-channel-detail-slot {
    grid-column: 2;
  }

  #view[data-view="profitCalculator"] .profit-calc-section-tools .small-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 360px) {
  #view[data-view="profitCalculator"] .profit-calc-entry-grid,
  #view[data-view="profitCalculator"] .profit-calc-entry-grid-costs {
    grid-template-columns: minmax(0, 1fr);
  }

  #view[data-view="profitCalculator"] .profit-calc-result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Customer creation: compact sectioned form with stable actions and dynamic rows. */
.customer-form-section-head {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
}

.customer-form-section-icon,
.customer-create-heading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius-md);
}

.customer-form-section-icon {
  width: 34px;
  height: 34px;
}

.customer-form-section-icon svg {
  width: 17px;
  height: 17px;
}

.customer-form-section-head > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.customer-form-section-head strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.customer-form-section-head small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.customer-required-mark {
  display: inline-flex;
  margin-left: var(--space-1);
  padding: 1px 5px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.4;
  vertical-align: 1px;
}

.customer-form-requirement {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.customer-create-modal {
  width: min(960px, 100%);
  height: min(820px, calc(100dvh - 44px));
  background: var(--surface-panel);
}

.customer-create-modal > .modal-header {
  align-items: center;
  min-height: 82px;
  padding: var(--space-4) var(--space-5);
}

.customer-create-modal-heading {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
}

.customer-create-heading-icon {
  width: 42px;
  height: 42px;
}

.customer-create-heading-icon svg {
  width: 21px;
  height: 21px;
}

.customer-create-modal-heading > div {
  min-width: 0;
}

.customer-create-modal-heading .eyebrow {
  margin-bottom: 1px;
  color: var(--brand);
}

.customer-create-modal-heading h2 {
  margin: 0;
}

.customer-create-modal-heading p:last-child {
  margin-top: 2px;
}

.customer-create-modal > .modal-body {
  padding: 0;
  background: var(--surface-subtle);
}

.customer-create-form {
  align-content: start;
  gap: var(--space-3);
  min-height: 100%;
  padding: var(--space-4) var(--space-5) 0;
}

.customer-create-form .customer-form-section {
  min-width: 0;
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-4);
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.customer-create-form :where(.field > span, .field > label) {
  color: var(--text-secondary);
  font-weight: 600;
}

.customer-create-form :where(input, select, textarea) {
  min-height: var(--control-md);
  border-radius: var(--radius-md);
}

.customer-create-form .editable-list {
  gap: var(--space-2);
}

.customer-create-form #edit-companies {
  counter-reset: customer-company-entry;
}

.customer-create-form #edit-contacts {
  counter-reset: customer-contact-entry;
}

.customer-create-form .editable-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  background: var(--surface-subtle);
  border-color: var(--border);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.customer-create-form .edit-company {
  counter-increment: customer-company-entry;
}

.customer-create-form .edit-contact {
  counter-increment: customer-contact-entry;
}

.customer-create-form .editable-row::before {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.customer-create-form .edit-company::before {
  content: "公司主体 " counter(customer-company-entry, decimal-leading-zero);
}

.customer-create-form .edit-contact::before {
  content: "联系人 " counter(customer-contact-entry, decimal-leading-zero);
}

.customer-create-form .editable-row > .form-grid {
  grid-column: 1 / -1;
  grid-row: 2;
}

.customer-create-form .editable-row > [data-entry-mutation="remove"] {
  grid-column: 2;
  grid-row: 1;
  min-height: var(--control-sm);
  padding: 4px 9px;
  color: var(--text-secondary);
  background: transparent;
  border-color: transparent;
  font-size: 11px;
}

.customer-create-form .editable-row > [data-entry-mutation="remove"]:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

.customer-create-form .customer-form-add-button {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  color: var(--brand);
  background: var(--surface-panel);
  border-style: dashed;
  border-color: var(--border-strong);
}

.customer-create-form > .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  justify-content: flex-end;
  margin: 0 calc(var(--space-5) * -1);
  padding: var(--space-3) var(--space-5);
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 20px rgba(15, 23, 42, .06);
  backdrop-filter: blur(10px);
}

.customer-create-form > .modal-actions .action-btn {
  min-width: 120px;
  min-height: var(--control-md);
  justify-content: center;
}

@media (max-width: 780px) {
  .customer-create-modal > .modal-header {
    min-height: 68px;
    padding: max(var(--space-3), env(safe-area-inset-top)) var(--space-3) var(--space-3);
  }

  .customer-create-modal-heading {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: var(--space-2);
  }

  .customer-create-heading-icon {
    width: 36px;
    height: 36px;
  }

  .customer-create-heading-icon svg {
    width: 18px;
    height: 18px;
  }

  .customer-create-modal-heading .eyebrow {
    display: none;
  }

  .customer-create-modal-heading h2 {
    font-size: 18px;
  }

  .customer-create-modal-heading p:last-child {
    overflow: hidden;
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .customer-create-form {
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .customer-create-form .customer-form-section {
    gap: 10px;
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  .customer-create-form .customer-form-section-head {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
  }

  .customer-create-form .customer-form-section-icon {
    width: 32px;
    height: 32px;
  }

  .customer-create-form .customer-form-requirement {
    display: none;
  }

  .customer-create-form .customer-form-section-head strong {
    font-size: 13px;
  }

  .customer-create-form .customer-form-section-head small {
    display: block;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .customer-create-form .customer-basic-grid,
  .customer-create-form .edit-company .form-grid,
  .customer-create-form .edit-contact .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .customer-create-form .customer-group-field,
  .customer-create-form .company-name-field,
  .customer-create-form .contact-phone-field,
  .customer-create-form .contact-wechat-field,
  .customer-create-form .contact-remark-field {
    grid-column: 1 / -1;
  }

  .customer-create-form .editable-row {
    gap: var(--space-2);
    padding: 10px;
  }

  .customer-create-form .editable-row > [data-entry-mutation="remove"] {
    min-height: 30px;
    padding: 3px 6px;
  }

  .customer-create-form .customer-form-add-button {
    min-height: 38px;
  }

  .customer-create-form > .modal-actions .action-btn {
    min-width: 0;
  }
}

@media (max-width: 360px) {
  .customer-create-form .customer-form-section-head small {
    white-space: normal;
  }

  .customer-create-form :where(.field > span, .field > label) {
    font-size: 11px;
  }
}

/* Follow history: stable audit modal and single-layer responsive records. */
.follow-history-modal {
  width: min(1120px, calc(100vw - 44px));
  height: min(820px, calc(100dvh - 44px));
}

.follow-history-modal-header {
  align-items: center;
  min-height: 82px;
  padding: var(--space-4) var(--space-5);
}

.follow-history-modal-heading {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
}

.follow-history-heading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius-md);
}

.follow-history-heading-icon svg {
  width: 21px;
  height: 21px;
}

.follow-history-modal-heading > div {
  min-width: 0;
}

.follow-history-modal-heading .eyebrow {
  margin-bottom: 1px;
  color: var(--brand);
}

.follow-history-modal-heading h2 {
  margin: 0;
}

.follow-history-modal-heading p:last-child {
  margin-top: 2px;
}

.follow-history-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.follow-history-total {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  min-height: 30px;
  padding: 4px 10px;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 11px;
  white-space: nowrap;
}

.follow-history-total strong {
  color: var(--brand);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.follow-history-modal-body {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: var(--surface-subtle);
}

.follow-history-filter-bar {
  position: relative;
  z-index: 4;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 132px 190px 250px;
  gap: 10px;
  align-items: end;
  padding: var(--space-3) var(--space-5);
  background: var(--surface-panel);
  border-bottom: 1px solid var(--border);
}

.follow-history-mobile-filter-toggle {
  display: none;
}

.follow-history-filter-field,
.follow-history-filter-bar .shared-date-range-field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.follow-history-filter-field > span:first-child,
.follow-history-filter-bar .shared-date-range-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.follow-history-filter-field > select,
.follow-history-input-shell,
.follow-history-filter-bar .report-date-picker-trigger {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-panel);
}

.follow-history-filter-field > select {
  padding: 0 28px 0 10px;
  color: var(--text);
}

.follow-history-input-shell {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
  padding: 0 10px;
}

.follow-history-input-shell > svg {
  width: 17px;
  height: 17px;
  color: var(--text-tertiary);
}

.follow-history-input-shell > input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.follow-history-input-shell:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.follow-history-filter-bar .shared-date-range-field {
  width: 100%;
}

.follow-history-filter-bar .report-date-picker {
  width: 100%;
}

.follow-history-filter-bar .report-date-picker-trigger {
  padding: 0 10px;
}

.follow-history-filter-bar .report-date-picker-trigger strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.follow-history-results-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 44px;
  padding: 8px var(--space-5);
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.follow-history-results-head > div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.follow-history-results-head strong {
  color: var(--text);
  font-size: 14px;
}

.follow-history-results-head > span {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.follow-history-card-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.follow-history-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(190px, .72fr) minmax(280px, 1.2fr) minmax(240px, .86fr);
  gap: var(--space-3);
  align-items: stretch;
  padding: var(--space-3);
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.follow-history-card.voided-item {
  background: #fffdfd;
  border-color: #edcbc7;
  opacity: 1;
}

.follow-history-card-head {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px 10px;
  align-content: start;
}

.follow-history-card-icon {
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius-md);
}

.follow-history-card.voided-item .follow-history-card-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.follow-history-card-icon svg {
  width: 17px;
  height: 17px;
}

.follow-history-card-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.follow-history-card-title strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.follow-history-card-title > span {
  color: var(--text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.follow-history-card-badges {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.follow-history-type-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  color: var(--info);
  background: var(--info-soft);
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
}

.follow-history-card-badges .status-chip {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 10px;
}

.follow-history-card-content {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  padding-inline: var(--space-3);
  border-inline: 1px solid var(--border);
}

.follow-history-card-content > span {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
}

.follow-history-card-content > p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.follow-history-void-reason {
  min-width: 0;
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr);
  gap: 5px;
  align-items: start;
  color: var(--danger);
  font-size: 10px;
  line-height: 1.4;
}

.follow-history-void-reason svg {
  width: 14px;
  height: 14px;
}

.follow-history-card-side {
  min-width: 0;
  display: grid;
  align-content: space-between;
  gap: var(--space-2);
}

.follow-history-card-facts {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.follow-history-card-facts > div {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 0 var(--space-2);
  border-left: 1px solid var(--border);
}

.follow-history-card-facts > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.follow-history-card-facts > div:last-child {
  padding-right: 0;
}

.follow-history-card-facts span {
  color: var(--text-secondary);
  font-size: 9px;
  line-height: 1.3;
}

.follow-history-card-facts strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.follow-history-void-meta {
  margin: 0;
  color: var(--danger);
  font-size: 10px;
  line-height: 1.35;
}

.follow-history-card-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
}

.follow-history-card-actions .proof-list {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
}

.follow-history-card-actions .proof-actions {
  min-width: 0;
}

.follow-history-card-actions .proof-actions .small-btn {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.follow-history-proof-empty,
.follow-history-proof-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  color: var(--text-secondary);
  font-size: 10px;
  white-space: nowrap;
}

.follow-history-proof-empty svg {
  width: 13px;
  height: 13px;
}

.follow-history-proof-count {
  padding: 2px 6px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
}

.follow-history-card-actions > .small-btn {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
}

.follow-history-empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: var(--space-6);
  color: var(--text-secondary);
  text-align: center;
  background: var(--surface-panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.follow-history-empty-state > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius-md);
}

.follow-history-empty-state > span svg {
  width: 20px;
  height: 20px;
}

.follow-history-empty-state strong {
  color: var(--text);
  font-size: 14px;
}

.follow-history-empty-state p {
  margin: 0;
  font-size: 12px;
}

.follow-history-modal-body > .pagination {
  min-height: 58px;
  padding: 9px var(--space-5);
  background: var(--surface-panel);
}

@media (max-width: 980px) and (min-width: 781px) {
  .follow-history-filter-bar {
    grid-template-columns: minmax(200px, 1fr) 120px 168px 220px;
    padding-inline: var(--space-4);
  }

  .follow-history-results-head,
  .follow-history-card-list,
  .follow-history-modal-body > .pagination {
    padding-inline: var(--space-4);
  }

  .follow-history-card {
    grid-template-columns: minmax(180px, .72fr) minmax(230px, 1.15fr) minmax(220px, .86fr);
    gap: 10px;
  }

  .follow-history-card-content {
    padding-inline: 10px;
  }
}

@media (max-width: 780px) {
  .follow-history-modal-header {
    min-height: 58px;
    padding: max(8px, env(safe-area-inset-top)) var(--space-3) 8px;
  }

  .follow-history-modal-heading {
    display: block;
  }

  .follow-history-heading-icon {
    display: none;
  }

  .follow-history-modal-heading .eyebrow {
    display: none;
  }

  .follow-history-modal-heading h2 {
    font-size: 17px;
    line-height: 1.25;
  }

  .follow-history-modal-heading p:last-child {
    overflow: hidden;
    margin-top: 1px;
    font-size: 10px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .follow-history-header-actions {
    gap: 6px;
  }

  .follow-history-total {
    display: none;
  }

  .modal-backdrop > .follow-history-modal > .follow-history-modal-body {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    min-height: 0;
    padding: 0 !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    background: var(--surface-subtle);
  }

  .follow-history-filter-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
    padding: 8px var(--space-3);
  }

  .follow-history-filter-bar.is-mobile-open {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .follow-history-query-field {
    grid-column: 1;
    gap: 0;
  }

  .follow-history-query-field > span:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .follow-history-mobile-filter-toggle {
    display: inline-flex;
    grid-column: 2;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 78px;
    min-height: 38px;
    padding-inline: 10px;
  }

  .follow-history-mobile-filter-toggle strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding-inline: 4px;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: var(--radius-pill);
    font-size: 9px;
  }

  .follow-history-mobile-filter-toggle.primary strong {
    color: var(--brand);
    background: var(--surface-panel);
  }

  .follow-history-filter-bar:not(.is-mobile-open) .follow-history-advanced-filter {
    display: none;
  }

  .follow-history-filter-bar.is-mobile-open .follow-history-status-filter {
    grid-column: 1;
  }

  .follow-history-filter-bar.is-mobile-open .follow-history-owner-filter {
    grid-column: 2;
    min-width: 0;
  }

  .follow-history-filter-bar.is-mobile-open .follow-history-date-filter {
    grid-column: 1 / -1;
  }

  .follow-history-filter-field > select,
  .follow-history-input-shell,
  .follow-history-filter-bar .report-date-picker-trigger {
    min-height: 38px;
  }

  .follow-history-results-head {
    min-height: 36px;
    padding: 6px var(--space-3);
  }

  .follow-history-results-head > div > span {
    display: none;
  }

  .follow-history-results-head strong {
    font-size: 13px;
  }

  .follow-history-results-head > span {
    font-size: 10px;
  }

  .follow-history-card-list {
    display: grid;
    align-content: start;
    gap: 0;
    margin: 8px var(--space-3);
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--surface-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overscroll-behavior: contain;
  }

  .follow-history-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
  }

  .follow-history-card:last-child {
    border-bottom: 0;
  }

  .follow-history-card.voided-item {
    background: var(--surface-panel);
    border-color: var(--border);
  }

  .follow-history-card-head {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    align-items: start;
    padding: 10px 10px 5px;
  }

  .follow-history-card-icon {
    display: none;
  }

  .follow-history-card-title strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.35;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .follow-history-card-title > span {
    font-size: 10px;
  }

  .follow-history-card-badges {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    max-width: 112px;
    flex-wrap: nowrap;
  }

  .follow-history-card-content {
    gap: 3px;
    padding: 5px 10px 8px;
    background: transparent;
    border: 0;
  }

  .follow-history-card-content > span {
    color: var(--brand);
    font-size: 9px;
  }

  .follow-history-card-content > p {
    display: block;
    overflow: visible;
    font-size: 12px;
    line-height: 1.5;
    -webkit-line-clamp: unset;
  }

  .follow-history-void-reason {
    margin-top: 3px;
    padding-top: 6px;
    border-top: 1px dashed #edcbc7;
  }

  .follow-history-card-side {
    gap: 7px;
    padding: 0 10px 10px;
  }

  .follow-history-card-facts {
    padding-block: 7px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .follow-history-card-facts > div {
    min-height: 32px;
    align-content: center;
    padding-inline: 8px;
  }

  .follow-history-card-facts strong {
    font-size: 11px;
  }

  .follow-history-void-meta {
    padding-left: 1px;
  }

  .follow-history-card-actions {
    justify-content: space-between;
    min-height: 30px;
  }

  .follow-history-card-actions .proof-list {
    flex: 1 1 auto;
    justify-content: flex-start;
  }

  .follow-history-card-actions .proof-actions .small-btn {
    max-width: min(190px, 52vw);
  }

  .follow-history-empty-state {
    min-height: 100%;
    border: 0;
    border-radius: 0;
  }

  .follow-history-modal-body > .pagination {
    min-height: 78px;
    padding: 7px var(--space-3) max(7px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 360px) {
  .follow-history-modal-heading p:last-child {
    display: none;
  }

  .follow-history-card-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .follow-history-card-badges {
    max-width: 84px;
  }

  .follow-history-type-chip,
  .follow-history-card-badges .status-chip {
    padding-inline: 5px;
  }

  .follow-history-card-facts > div {
    padding-inline: 5px;
  }
}

/* Shared mobile task-card hierarchy: Order Todo is the reference for finance and inventory. */
@media (max-width: 780px) {
  .task-standard-card {
    min-width: 0;
    overflow: hidden;
    background: var(--surface, #fff);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: none;
  }

  /* Finance rows use the table row as the single card surface. */
  #view[data-view="finance"] .ledger-card-table tbody {
    gap: 9px;
  }

  #view[data-view="finance"] .ledger-card-table tr {
    gap: 0;
    overflow: hidden;
    padding: 0;
    background: var(--surface, #fff);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: none;
  }

  #view[data-view="finance"] .ledger-card-table tr:hover {
    background: var(--surface, #fff);
  }

  #view[data-view="finance"] :is(.finance-ledger-summary-card, .finance-flow-card) {
    gap: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  #view[data-view="finance"] :is(.finance-ledger-summary-head, .finance-flow-card-head) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 12px 12px 0;
  }

  #view[data-view="finance"] :is(.finance-ledger-summary-state, .finance-flow-card-state) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-width: 0;
  }

  #view[data-view="finance"] :is(.finance-ledger-summary-head, .finance-flow-card-head) .order-source-badge {
    position: static;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 6px;
  }

  #view[data-view="finance"] :is(.finance-ledger-summary-head, .finance-flow-card-head) > .status-chip,
  #view[data-view="finance"] .finance-ledger-summary-state > .status-chip {
    min-width: 0;
    min-height: 26px;
    max-width: none;
    overflow: hidden;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] :is(.finance-ledger-summary-title, .finance-flow-card-title) {
    min-width: 0;
    margin: 0;
    padding: 9px 12px 0;
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.25;
  }

  #view[data-view="finance"] :is(.finance-ledger-total-row, .finance-flow-facts) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 0;
    min-width: 0;
    margin: 8px 12px 0;
    padding: 0 0 10px;
    border: 0;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="finance"] :is(.finance-ledger-total-row, .finance-flow-facts) > div {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 0 10px 0 0;
  }

  #view[data-view="finance"] :is(.finance-ledger-total-row, .finance-flow-facts) > div:nth-child(even) {
    padding-right: 0;
    padding-left: 12px;
    border-left: 1px solid var(--border);
  }

  #view[data-view="finance"] :is(.finance-ledger-total-row, .finance-flow-facts) span {
    display: flex;
    gap: 4px;
    align-items: center;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.2;
  }

  #view[data-view="finance"] :is(.finance-ledger-total-row, .finance-flow-facts) span svg {
    width: 13px;
    height: 13px;
  }

  #view[data-view="finance"] :is(.finance-ledger-total-row, .finance-flow-facts) strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: 0;
    margin: 0 12px;
    padding: 9px 0;
    border: 0;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) > div {
    display: grid;
    gap: 2px;
    align-content: center;
    min-width: 0;
    padding: 0 7px;
    text-align: center;
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) > div:first-child {
    padding-left: 0;
    border-left: 0;
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) > div + div {
    padding-left: 7px;
    border-left: 1px solid var(--border);
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) > div:last-child {
    padding-right: 0;
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) span {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 10.5px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) :is(strong, .finance-flow-source) {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  #view[data-view="finance"] .finance-flow-amount-row strong {
    white-space: normal;
  }

  #view[data-view="finance"] .finance-flow-source :is(button, a) {
    max-width: 100%;
  }

  #view[data-view="finance"] .finance-flow-note {
    display: grid;
    gap: 2px;
    min-width: 0;
    margin: 0 12px;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="finance"] .finance-flow-card-foot {
    min-width: 0;
    padding: 8px 12px 10px;
  }

  #view[data-view="finance"] .real-fund-flow-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 0;
  }

  #view[data-view="finance"] .real-fund-flow-toolbar h2 {
    font-size: 17px;
  }

  #view[data-view="finance"] .real-fund-flow-toolbar p {
    margin-top: 3px;
    font-size: 10.5px;
    line-height: 1.35;
  }

  #view[data-view="finance"] .real-fund-flow-count {
    min-height: 28px;
    padding: 4px 8px;
  }

  #view[data-view="finance"] .real-fund-flow-table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  #view[data-view="finance"] .real-fund-flow-table {
    min-width: 0;
  }

  #view[data-view="finance"] .real-fund-flow-table :is(th, td),
  #view[data-view="finance"] .real-fund-flow-table td.mobile-card-cell {
    width: 100%;
  }

  #view[data-view="finance"] .real-fund-flow-table td:not(.mobile-card-cell) {
    display: none;
  }

  #view[data-view="finance"] .real-fund-flow-account-desktop {
    display: none;
  }

  #view[data-view="finance"] .real-fund-flow-card-head {
    padding: 10px 11px 0;
  }

  #view[data-view="finance"] .real-fund-flow-card-head time {
    color: var(--text-secondary);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 26px;
    white-space: nowrap;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-card-state {
    gap: 7px;
    flex-wrap: nowrap;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-card-state > .status-chip {
    min-width: 0;
    min-height: 26px;
    overflow: hidden;
    padding: 0;
    color: var(--text-primary);
    background: transparent;
    border: 0;
    font-size: 12px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-card-title {
    padding: 7px 11px 0;
    font-size: 15px;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-amount-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 11px;
    padding: 8px 0;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-amount-row > div {
    padding: 0 9px;
    text-align: left;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-amount-row > div:first-child {
    padding-left: 0;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-amount-row > div:last-child {
    padding-right: 0;
  }

  #view[data-view="finance"] .real-fund-flow-card .finance-flow-amount-row strong {
    font-size: 14px;
    white-space: nowrap;
  }

  #view[data-view="finance"] .real-fund-flow-reference {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 7px;
    padding: 7px 11px 9px;
  }

  #view[data-view="finance"] .real-fund-flow-reference > span {
    color: var(--text-secondary);
    font-size: 10px;
    line-height: 1.35;
  }

  #view[data-view="finance"] .real-fund-flow-reference > strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 10.5px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .real-fund-flow-reference > p {
    grid-column: 1 / -1;
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #view[data-view="finance"] .ledger-card-table .mobile-action-cell {
    padding: 0 6px;
    border-top: 1px solid var(--border);
  }

  #view[data-view="finance"] .ledger-action-row,
  #view[data-view="inventory"] :where(.inventory-batch-mobile-actions, .inventory-reservation-mobile-actions) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 0;
    padding: 0 6px;
  }

  #view[data-view="finance"] .ledger-action-row {
    padding: 0;
  }

  #view[data-view="finance"] .ledger-action-row .small-btn,
  #view[data-view="inventory"] :where(.inventory-batch-mobile-actions, .inventory-reservation-mobile-actions) .small-btn {
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 6px 4px;
    color: var(--text-primary);
    background: transparent;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
  }

  #view[data-view="finance"] .ledger-action-row .small-btn:first-child,
  #view[data-view="inventory"] :where(.inventory-batch-mobile-actions, .inventory-reservation-mobile-actions) .small-btn:first-child {
    border-left: 0;
  }

  #view[data-view="finance"] .ledger-action-row .small-btn.primary,
  #view[data-view="inventory"] :where(.inventory-batch-mobile-actions, .inventory-reservation-mobile-actions) .small-btn.primary {
    color: var(--brand);
  }

  #view[data-view="finance"] .ledger-action-row .small-btn.warning,
  #view[data-view="inventory"] :where(.inventory-batch-mobile-actions, .inventory-reservation-mobile-actions) .small-btn.warning {
    color: #b45309;
  }

  #view[data-view="finance"] .ledger-action-row .small-btn.danger,
  #view[data-view="inventory"] :where(.inventory-batch-mobile-actions, .inventory-reservation-mobile-actions) .small-btn.danger {
    color: var(--danger, #b42318);
  }

  /* Inventory batch, pre-reservation and flow cards share the same single-card rhythm. */
  #view[data-view="inventory"] :where(.inventory-batch-mobile-card, .inventory-reservation-mobile-card, .inventory-log-mobile-card) {
    border-color: var(--border);
    border-radius: 10px;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-head, .inventory-reservation-mobile-head, .inventory-log-mobile-head) {
    padding: 12px 12px 10px;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-heading h3, .inventory-reservation-mobile-heading h3, .inventory-log-mobile-head h3) {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.25;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-context, .inventory-log-mobile-meta) {
    margin: 0 12px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="inventory"] .inventory-batch-mobile-context > div,
  #view[data-view="inventory"] .inventory-log-mobile-meta > p {
    padding: 0 10px 10px 0;
  }

  #view[data-view="inventory"] .inventory-batch-mobile-context > div + div,
  #view[data-view="inventory"] .inventory-log-mobile-meta > p + p {
    padding-right: 0;
    padding-left: 12px;
    border-left: 1px solid var(--border);
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) {
    margin: 0 12px;
    padding: 9px 0;
    border-top: 0;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) > div {
    padding: 0 7px;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) > div:first-child {
    padding-left: 0;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) > div:last-child {
    padding-right: 0;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) > div + div {
    border-left-color: var(--border);
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) span {
    font-size: 11px;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) strong {
    font-size: 12px;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-meta, .inventory-reservation-mobile-route, .inventory-reservation-mobile-batches) {
    padding-right: 12px;
    padding-left: 12px;
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-remark, .inventory-reservation-mobile-remark, .inventory-reservation-mobile-state-note, .inventory-log-mobile-reason) {
    padding-right: 12px;
    padding-left: 12px;
    border-top-color: var(--border);
  }

  #view[data-view="inventory"] :where(.inventory-batch-mobile-actions, .inventory-reservation-mobile-actions) {
    border-top: 1px solid var(--border);
  }

  #view[data-view="inventory"] .inventory-reservation-mobile-result {
    min-height: 40px;
    border-top-color: var(--border);
  }
}

@media (max-width: 360px) {
  #view[data-view="finance"] :is(.finance-ledger-summary-title, .finance-flow-card-title),
  #view[data-view="inventory"] :where(.inventory-batch-mobile-heading h3, .inventory-reservation-mobile-heading h3, .inventory-log-mobile-head h3) {
    font-size: 15px;
  }

  #view[data-view="finance"] :is(.finance-ledger-balance-band, .finance-flow-amount-row) :is(strong, .finance-flow-source),
  #view[data-view="inventory"] :where(.inventory-batch-mobile-facts, .inventory-reservation-mobile-facts, .inventory-log-mobile-facts) strong {
    font-size: 11px;
  }
}

/* Finance workspace navigation: organize the page by recurring finance tasks. */
#view[data-view="finance"] .finance-workspace-shell {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 14px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d8e3ef;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 22px rgba(30, 64, 102, .05);
}

#view[data-view="finance"] .finance-task-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

#view[data-view="finance"] .finance-task-tab {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 1px 9px;
  align-items: center;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
  background: #f8fafc;
  border: 1px solid #dce5ef;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

#view[data-view="finance"] .finance-task-tab:hover {
  border-color: #8fb6df;
  box-shadow: 0 5px 14px rgba(31, 103, 178, .09);
  transform: translateY(-1px);
}

#view[data-view="finance"] .finance-task-tab > svg {
  grid-row: 1 / 3;
  width: 34px;
  height: 34px;
  padding: 8px;
  color: #2467aa;
  background: #eaf3fd;
  border-radius: 10px;
}

#view[data-view="finance"] .finance-task-tab > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

#view[data-view="finance"] .finance-task-tab strong,
#view[data-view="finance"] .finance-task-tab small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view[data-view="finance"] .finance-task-tab strong { font-size: 12.5px; }
#view[data-view="finance"] .finance-task-tab small { color: var(--muted); font-size: 10px; }

#view[data-view="finance"] .finance-task-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, #175a9d 0%, #2675bf 100%);
  border-color: #175a9d;
  box-shadow: 0 7px 18px rgba(24, 90, 157, .2);
}

#view[data-view="finance"] .finance-task-tab.is-active > svg {
  color: #fff;
  background: rgba(255, 255, 255, .16);
}

#view[data-view="finance"] .finance-task-tab.is-active small { color: rgba(255, 255, 255, .8); }

#view[data-view="finance"] .finance-workspace-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 9px;
  background: #f6f9fc;
  border: 1px solid #e0e8f1;
  border-radius: var(--radius-md);
}

#view[data-view="finance"] .finance-workspace-action-label { color: var(--ink); font-size: 12px; font-weight: 800; white-space: nowrap; }

#view[data-view="finance"] .finance-workspace-action-list {
  min-width: 0;
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

#view[data-view="finance"] .finance-workspace-action {
  min-width: 0;
  min-height: 38px;
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 6px 11px;
  color: #26425f;
  text-align: left;
  background: #fff;
  border: 1px solid #cfdbe8;
  border-radius: var(--radius-md);
  cursor: pointer;
}

#view[data-view="finance"] .finance-workspace-action svg { width: 17px; height: 17px; color: #2467aa; }
#view[data-view="finance"] .finance-workspace-action strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view[data-view="finance"] .finance-workspace-action strong { font-size: 11.5px; }

#view[data-view="finance"] .finance-workspace-action.is-primary {
  color: #26425f;
  background: #fff;
  border-color: #cfdbe8;
  box-shadow: none;
}

#view[data-view="finance"] .finance-workspace-action.is-primary svg { color: #2467aa; }
#view[data-view="finance"] .finance-workspace-action:focus-visible,
#view[data-view="finance"] .finance-task-tab:focus-visible { outline: 3px solid rgba(31, 103, 178, .25); outline-offset: 2px; }

#view[data-view="finance"] .finance-real-fund-flow { margin-top: 0; }

#view[data-view="finance"] .real-fund-disclosure {
  margin: 0 0 10px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #dfe6ee;
  border-radius: var(--radius-md);
}

#view[data-view="finance"] .real-fund-disclosure-summary {
  display: grid;
  grid-template-columns: minmax(170px, .65fr) minmax(420px, 1.6fr) auto 18px;
  gap: 14px;
  align-items: center;
  padding: 10px 13px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

#view[data-view="finance"] .real-fund-disclosure-summary::-webkit-details-marker { display: none; }

#view[data-view="finance"] .real-fund-disclosure-copy { min-width: 0; display: grid; gap: 1px; }
#view[data-view="finance"] .real-fund-disclosure-copy strong { font-size: 13px; }
#view[data-view="finance"] .real-fund-disclosure-copy small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

#view[data-view="finance"] .real-fund-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

#view[data-view="finance"] .real-fund-summary > span { min-width: 0; display: grid; gap: 1px; }
#view[data-view="finance"] .real-fund-summary small { color: var(--muted); font-size: 9.5px; }
#view[data-view="finance"] .real-fund-summary strong { overflow: hidden; color: #30475f; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

#view[data-view="finance"] .real-fund-disclosure-chevron { width: 17px; height: 17px; color: var(--muted); transition: transform .16s ease; }
#view[data-view="finance"] .real-fund-disclosure[open] .real-fund-disclosure-chevron { transform: rotate(180deg); }

#view[data-view="finance"] .real-fund-disclosure-body {
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e3e9f0;
}

#view[data-view="finance"] .real-fund-setup-action { display: flex; justify-content: flex-end; margin-bottom: 10px; }

#view[data-view="finance"] .real-fund-account-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

#view[data-view="finance"] .real-fund-account-card {
  display: grid;
  gap: 8px;
  padding: 9px 10px;
  background: #fbfcfe;
  border-radius: 10px;
  box-shadow: none;
}

#view[data-view="finance"] .real-fund-account-card header { min-width: 0; gap: 6px; }
#view[data-view="finance"] .real-fund-account-statuses,
#view[data-view="finance"] .real-fund-account-actions { min-width: 0; display: flex; gap: 4px; align-items: center; }
#view[data-view="finance"] .real-fund-account-statuses { overflow: hidden; }
#view[data-view="finance"] .real-fund-account-actions { flex: 0 0 auto; }
#view[data-view="finance"] .real-fund-account-card :is(.order-source-badge, .status-chip) { padding: 3px 6px; font-size: 9px; white-space: nowrap; }
#view[data-view="finance"] .real-fund-account-toggle { min-height: 34px; padding: 4px 8px; font-size: 10px; }
#view[data-view="finance"] .real-fund-account-toggle.is-enable { color: #1768b1; background: #edf6ff; border-color: #a9caea; }
#view[data-view="finance"] .real-fund-account-actions .icon-btn { width: 34px; height: 34px; min-height: 34px; }
#view[data-view="finance"] .real-fund-account-actions .icon-btn svg { width: 14px; height: 14px; }

#view[data-view="finance"] .real-fund-account-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

#view[data-view="finance"] .real-fund-account-main > div { min-width: 0; }
#view[data-view="finance"] .real-fund-account-card h3 { overflow: hidden; margin: 0; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
#view[data-view="finance"] .real-fund-account-card p { overflow: hidden; margin: 2px 0 0; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
#view[data-view="finance"] .real-fund-account-balance { min-width: 92px; display: grid; gap: 1px; margin: 0; text-align: right; }
#view[data-view="finance"] .real-fund-account-balance small { color: var(--muted); font-size: 9px; font-weight: 500; }
#view[data-view="finance"] .real-fund-account-balance strong { color: #30475f; font-size: 15px; white-space: nowrap; }
#view[data-view="finance"] .real-fund-account-card.is-disabled { opacity: .72; border-style: dashed; }

@media (min-width: 781px) {
  #view[data-view="finance"] .real-fund-account-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .finance-workspace-shell {
    gap: 7px;
    margin-bottom: 7px;
    padding: 8px;
    border-radius: var(--radius-md);
    box-shadow: none;
  }

  #view[data-view="finance"] .finance-task-tabs::-webkit-scrollbar,
  #view[data-view="finance"] .finance-workspace-action-list::-webkit-scrollbar { display: none; }

  #view[data-view="finance"] .finance-task-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
  }

  #view[data-view="finance"] .finance-task-tab {
    width: 100%;
    min-height: 44px;
    display: flex;
    justify-content: center;
    padding: 5px 3px;
    text-align: center;
  }

  #view[data-view="finance"] .finance-task-tab > svg { display: none; }
  #view[data-view="finance"] .finance-task-tab strong { font-size: 10px; }
  #view[data-view="finance"] .finance-task-tab small { display: none; }

  #view[data-view="finance"] .finance-workspace-actions {
    display: block;
    padding: 6px;
  }

  #view[data-view="finance"] .finance-workspace-action-label { display: none; }

  #view[data-view="finance"] .finance-workspace-action-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
    gap: 5px;
    overflow: visible;
  }

  #view[data-view="finance"] .finance-workspace-action {
    width: 100%;
    min-height: 36px;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    padding: 5px 3px;
    text-align: center;
  }

  #view[data-view="finance"] .finance-workspace-action svg { display: none; }
  #view[data-view="finance"] .finance-workspace-action strong { font-size: 10px; }

  #view[data-view="finance"] .real-fund-disclosure-summary {
    grid-template-columns: minmax(0, 1fr) auto 16px;
    gap: 8px;
    padding: 8px 10px;
  }

  #view[data-view="finance"] .real-fund-summary { display: block; }
  #view[data-view="finance"] .real-fund-summary > span { display: flex; gap: 5px; align-items: baseline; }
  #view[data-view="finance"] .real-fund-summary-secondary { display: none !important; }
  #view[data-view="finance"] .real-fund-disclosure-summary > .status-chip { display: none; }
  #view[data-view="finance"] .real-fund-disclosure-body { padding: 8px; }
  #view[data-view="finance"] .real-fund-account-grid { grid-template-columns: 1fr; }
  #view[data-view="finance"] .real-fund-account-card { padding: 8px 9px; }
  #view[data-view="finance"] .real-fund-account-card h3 { font-size: 11.5px; }
  #view[data-view="finance"] .real-fund-account-balance { min-width: 86px; }
  #view[data-view="finance"] .real-fund-account-balance strong { font-size: 13px; }
}

/* Acceptance workspace: faster scanning and a compact mobile first screen. */
#view[data-view="finance"] .finance-acceptance-page .acceptance-held-card {
  grid-template-columns: 122px minmax(195px, 1.1fr) minmax(205px, 1fr) minmax(300px, 1.5fr) auto;
  gap: 10px;
}

#view[data-view="finance"] .finance-acceptance-page .acceptance-held-number strong,
#view[data-view="finance"] .finance-acceptance-page .acceptance-held-amount strong {
  font-variant-numeric: tabular-nums;
}

#view[data-view="finance"] .finance-acceptance-page .acceptance-held-amount strong {
  white-space: nowrap;
}

#view[data-view="finance"] .finance-acceptance-page .acceptance-held-number strong {
  line-height: 1.45;
}

#view[data-view="finance"] .finance-acceptance-page .acceptance-held-actions .small-btn {
  min-height: 34px;
  border-radius: 7px;
}

#view[data-view="finance"] .finance-acceptance-page .acceptance-held-actions .small-btn:not(.danger):not(.primary):first-child {
  color: #315c88;
  background: #fff;
}

#view[data-view="finance"] .finance-acceptance-page .acceptance-held-actions .small-btn:not(.danger):not(.primary):nth-child(2) {
  color: #195f9f;
  border-color: #b9d2ea;
  background: #f3f8fd;
}

@media (max-width: 1180px) and (min-width: 781px) {
  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-card {
    grid-template-columns: 92px minmax(175px, 1.2fr) minmax(125px, .8fr) minmax(250px, 1.5fr) auto;
    gap: 8px;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .finance-acceptance-page {
    margin-top: 10px;
    padding: 11px 14px 12px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-page-toolbar {
    min-height: 49px;
    align-items: center;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-page-toolbar h2 {
    margin: 0 0 4px;
    font-size: 18px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-page-toolbar p {
    max-width: 275px;
    font-size: 10.5px;
    line-height: 1.35;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-page-count {
    min-height: 24px;
    padding-inline: 7px;
    font-size: 11px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary {
    margin: 4px 0 7px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary > .acceptance-summary-action {
    min-height: 49px;
    padding: 4px 2px;
    border-radius: 9px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary-copy .acceptance-summary-label {
    font-size: 9px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary-copy strong,
  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary-action.is-money .acceptance-summary-copy strong {
    font-size: 10px;
    letter-spacing: -.035em;
  }

  #view[data-view="finance"] .finance-acceptance-page .finance-filter-toggle {
    min-height: 37px;
    margin-bottom: 7px;
    background: #fff;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-filter-panel {
    display: none;
    margin: 0 0 8px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-filter-panel.is-expanded {
    display: grid;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-grid {
    gap: 7px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto;
    gap: 0;
    padding: 10px;
    border-radius: 10px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-status {
    min-height: 24px;
    gap: 5px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-status small {
    font-size: 10px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-number {
    margin: 7px 0 6px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-number span,
  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-amount span,
  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-facts dt {
    font-size: 10px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-number strong {
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.4;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-amount {
    border-radius: 8px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-amount > div {
    padding: 6px 8px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-amount strong {
    margin-top: 2px;
    font-size: 14px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-amount > div:last-child strong {
    font-size: 13px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-facts {
    gap: 6px 9px;
    margin: 7px 0;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-facts dd {
    margin-top: 2px;
    font-size: 11.5px;
    line-height: 1.4;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-facts > div > small {
    margin-top: 1px;
    max-height: 30px;
    overflow: hidden;
    font-size: 9.5px;
    line-height: 1.5;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-circulation {
    display: none;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-actions {
    gap: 6px;
    padding-top: 7px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-actions .small-btn {
    height: 35px;
    min-height: 35px;
    font-size: 11px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-held-pagination {
    margin-top: 6px;
  }
}

@media (max-width: 350px) {
  #view[data-view="finance"] .finance-acceptance-page {
    padding-inline: 9px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-page-toolbar p {
    max-width: 230px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary-copy .acceptance-summary-label {
    font-size: 8.5px;
  }

  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary-copy strong,
  #view[data-view="finance"] .finance-acceptance-page .acceptance-summary-action.is-money .acceptance-summary-copy strong {
    font-size: 8.5px;
  }
}


/* Customer ledger: compact account-first hierarchy on desktop and mobile. */
#view[data-view="finance"] .finance-customer-panel {
  gap: 10px;
}

#view[data-view="finance"] .finance-ledger-balance-summary small {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

#view[data-view="finance"] .finance-ledger-balance-summary small svg {
  width: 13px;
  height: 13px;
  color: #52708e;
}

#view[data-view="finance"] .finance-ledger-balance-summary.is-customer {
  grid-template-columns: 1.16fr 1fr 1fr;
  background: #f7f9fc;
}

#view[data-view="finance"] .finance-ledger-balance-summary.is-customer > span:first-child {
  background: #eef5fc;
}

#view[data-view="finance"] .finance-ledger-balance-summary.is-customer > span:first-child strong {
  color: #174f87;
  font-size: 15px;
}

#view[data-view="finance"] .customer-ledger-desktop-identity {
  min-width: 0;
  display: flex;
  gap: 9px;
  align-items: center;
}

#view[data-view="finance"] .customer-ledger-avatar {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  color: #2368a9;
  background: #edf5fd;
  border: 1px solid #d8e8f7;
  border-radius: 8px;
}

#view[data-view="finance"] .customer-ledger-avatar svg {
  width: 15px;
  height: 15px;
}

#view[data-view="finance"] .customer-ledger-desktop-identity > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

#view[data-view="finance"] .customer-ledger-desktop-identity strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view[data-view="finance"] .customer-ledger-desktop-identity small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

#view[data-view="finance"] .customer-ledger-row {
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

#view[data-view="finance"] .customer-ledger-row:hover {
  background: #f8fbff;
  box-shadow: inset 0 1px #dce9f6, inset 0 -1px #dce9f6;
}

#view[data-view="finance"] .customer-ledger-row td:nth-child(2),
#view[data-view="finance"] .customer-ledger-row td:nth-child(3),
#view[data-view="finance"] .customer-ledger-row td:nth-child(4) {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

#view[data-view="finance"] .customer-ledger-detail-button {
  min-width: 64px;
}

@media (min-width: 781px) {
  #view[data-view="finance"] .finance-customer-panel .ledger-card-table th:first-child {
    width: 21%;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-card-table th:nth-child(2),
  #view[data-view="finance"] .finance-customer-panel .ledger-card-table th:nth-child(3),
  #view[data-view="finance"] .finance-customer-panel .ledger-card-table th:nth-child(4) {
    width: 11.5%;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-card-table th:nth-child(5) {
    width: 10.5%;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-card-table th:nth-child(6) {
    width: 10%;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-card-table th:last-child {
    width: 24%;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-action-row {
    flex-wrap: nowrap;
    gap: 5px;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-action-row .small-btn {
    min-width: 0;
    padding-inline: 8px;
    font-size: 11.5px;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .finance-customer-panel .finance-panel-heading p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-customer {
    min-height: 50px;
    grid-template-columns: 1.16fr 1fr 1fr;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-customer > span {
    min-height: 50px;
    padding: 6px 7px;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-customer small {
    gap: 3px;
    font-size: 9.5px;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-customer small svg {
    width: 11px;
    height: 11px;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-customer strong,
  #view[data-view="finance"] .finance-ledger-balance-summary.is-customer > span:first-child strong {
    font-size: 11.5px;
    line-height: 1.2;
  }

  #view[data-view="finance"] .customer-ledger-desktop-identity {
    display: none;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-summary-head {
    align-items: center;
    padding: 10px 11px 8px;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-summary-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-summary-head > .status-chip {
    flex: 0 0 auto;
    min-height: 24px;
    max-width: 108px;
    padding: 0 7px;
    overflow: hidden;
    color: #196b4b;
    background: #eef8f3;
    border: 1px solid #cce8da;
    border-radius: 999px;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-summary-head > .status-chip.danger {
    color: #b42318;
    background: #fff3f1;
    border-color: #f5c7c2;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .customer-ledger-list-balance {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 9px 11px;
  }

  #view[data-view="finance"] .customer-ledger-balance-total {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  #view[data-view="finance"] .customer-ledger-balance-total > span {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
  }

  #view[data-view="finance"] .customer-ledger-balance-total > strong {
    min-width: 0;
    overflow: hidden;
    color: #174f87;
    font-size: 18px;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .customer-ledger-balance-total > strong.danger-text {
    color: var(--danger);
  }

  #view[data-view="finance"] .customer-ledger-balance-meta {
    min-width: 0;
    display: grid;
    gap: 4px;
    justify-items: end;
  }

  #view[data-view="finance"] .customer-ledger-balance-state {
    color: #196b4b;
    font-size: 10.5px;
    font-weight: 800;
  }

  #view[data-view="finance"] .customer-ledger-balance-state.is-debt {
    color: var(--danger);
  }

  #view[data-view="finance"] .customer-ledger-balance-state.is-settled {
    color: var(--muted);
  }

  #view[data-view="finance"] .customer-ledger-balance-meta time {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    color: var(--text-secondary);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
  }

  #view[data-view="finance"] .customer-ledger-balance-meta time svg {
    width: 12px;
    height: 12px;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .finance-customer-panel .finance-ledger-balance-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 11px;
    padding: 8px 0;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-balance-band > div {
    align-items: start;
    padding: 0 9px 0 0;
    text-align: left;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-balance-band > div + div {
    padding-right: 0;
    padding-left: 10px;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-balance-band span {
    display: inline-flex;
    gap: 4px;
    align-items: center;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-balance-band span svg {
    width: 12px;
    height: 12px;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-balance-band strong {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-customer-panel .mobile-action-cell {
    padding: 7px 10px 9px;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  #view[data-view="finance"] .finance-customer-panel .ledger-action-row .small-btn {
    min-height: 34px;
    padding: 0 6px;
    font-size: 11.5px;
  }
}

@media (max-width: 360px) {
  #view[data-view="finance"] .finance-customer-panel .finance-ledger-summary-title {
    font-size: 14px;
  }

  #view[data-view="finance"] .customer-ledger-balance-total > strong {
    font-size: 16px;
  }

  #view[data-view="finance"] .finance-customer-panel .finance-ledger-summary-head > .status-chip {
    max-width: 96px;
  }
}

/* Shipping: compact source filters and readable dispatch tasks. */
#view[data-view="shipping"] .shipping-panel { padding: var(--space-4); }
#view[data-view="shipping"] .shipping-summary-grid {
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
#view[data-view="shipping"] .shipping-summary-grid .metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 52px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-panel);
  box-shadow: none;
}
#view[data-view="shipping"] .shipping-summary-grid .metric.active {
  background: var(--brand-soft);
  border-color: var(--brand);
}
#view[data-view="shipping"] .shipping-summary-grid .metric-value {
  margin: 0;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#view[data-view="shipping"] .shipping-summary-grid .metric-note,
#view[data-view="shipping"] .shipping-summary-grid .metric-label svg { display: none; }
#view[data-view="shipping"] .shipping-filters {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px) auto;
  gap: var(--space-2);
  padding: var(--space-2);
  border-color: var(--border);
  background: var(--surface-subtle);
}
#view[data-view="shipping"] .shipping-filters > * { min-width: 0; }
#view[data-view="shipping"] .shipping-filter-actions { display: flex; gap: var(--space-2); }
#view[data-view="shipping"] .shipping-filter-actions .small-btn { min-height: var(--control-md); white-space: nowrap; }
#view[data-view="shipping"] .shipping-filters select { height: var(--control-md); }
#view[data-view="shipping"] .shipping-filter-note { flex-direction: row; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
#view[data-view="shipping"] .shipping-list-head {
  margin: var(--space-4) 0 var(--space-2);
  align-items: center;
}
#view[data-view="shipping"] .shipping-list-head > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); }
#view[data-view="shipping"] .shipping-list-head p { margin: 0; font-size: 12px; }
#view[data-view="shipping"] .shipping-list-head > .tag { display: none; }
#view[data-view="shipping"] .shipping-task-card {
  grid-template-columns: 88px minmax(180px, 1.1fr) 64px minmax(240px, 1.5fr) 104px 100px;
  gap: var(--space-3);
  box-shadow: none;
  border-radius: var(--radius-lg);
}
#view[data-view="shipping"] .shipping-task-card:hover { background: var(--surface-subtle); }
#view[data-view="shipping"] .shipping-card-action .small-btn { min-height: var(--control-md); }
#view[data-view="shipping"] .shipping-batch-line,
#view[data-view="shipping"] .shipping-vehicle-line {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 24px;
  font-variant-numeric: tabular-nums;
}
#view[data-view="shipping"] .shipping-batch-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}
#view[data-view="shipping"] .shipping-card-route { gap: var(--space-2); }
#view[data-view="shipping"] .shipping-route-row { align-items: start; }
@media (min-width: 781px) and (max-width: 1180px) {
  #view[data-view="shipping"] .shipping-task-card {
    grid-template-columns: 92px minmax(0, 1fr) 80px 104px 100px;
    grid-template-areas: "source subject owner wait action" "route route route route route";
  }
  #view[data-view="shipping"] .shipping-card-route {
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
  }
  #view[data-view="shipping"] .shipping-route-row > span { white-space: normal; overflow-wrap: anywhere; }
}
@media (max-width: 780px) {
  #view[data-view="shipping"] .shipping-panel { padding: var(--space-3); }
  #view[data-view="shipping"] .shipping-summary-grid { gap: var(--space-1); margin-bottom: var(--space-2); }
  #view[data-view="shipping"] .shipping-summary-grid .metric {
    padding: var(--space-2);
    min-height: var(--control-lg);
    gap: var(--space-1);
    flex-wrap: wrap;
  }
  #view[data-view="shipping"] .shipping-summary-grid .metric-label { font-size: 11px; }
  #view[data-view="shipping"] .shipping-summary-grid .metric-value { font-size: 16px; }
  #view[data-view="shipping"] .shipping-filters { grid-template-columns: minmax(0, 1fr) auto; }
  #view[data-view="shipping"] .shipping-filters .search-wrap { grid-column: 1 / -1; }
  #view[data-view="shipping"] .shipping-filter-actions { gap: var(--space-1); }
  #view[data-view="shipping"] .shipping-filter-actions .small-btn { padding-inline: var(--space-2); gap: var(--space-1); font-size: 12px; }
  #view[data-view="shipping"] .shipping-filter-actions svg { width: 14px; height: 14px; }
  #view[data-view="shipping"] .shipping-list-head { margin-top: var(--space-3); }
  #view[data-view="shipping"] .shipping-list-head h3 { font-size: 15px; }
  #view[data-view="shipping"] .shipping-list-head p { font-size: 11px; }
  #view[data-view="shipping"] .shipping-task-card {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "source action" "subject subject" "owner wait" "route route";
    gap: var(--space-2);
    padding: var(--space-3);
    min-height: 0;
  }
  #view[data-view="shipping"] .shipping-task-title {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: var(--space-2);
    align-items: baseline;
  }
  #view[data-view="shipping"] .shipping-task-title > * { white-space: normal; overflow-wrap: anywhere; }
  #view[data-view="shipping"] .shipping-task-title span { color: var(--brand); font-size: 13px; }
  #view[data-view="shipping"] .shipping-card-wait { display: flex; align-items: center; gap: var(--space-1); }
  #view[data-view="shipping"] .shipping-card-wait > span { display: inline-flex; font-size: 11px; }
  #view[data-view="shipping"] .shipping-card-wait > span svg { display: none; }
  #view[data-view="shipping"] .shipping-card-wait small { display: none; }
  #view[data-view="shipping"] .shipping-card-owner { display: flex; align-items: center; gap: var(--space-1); }
  #view[data-view="shipping"] .shipping-card-route { gap: var(--space-1); padding-top: var(--space-2); border-top: 1px solid var(--border); }
  #view[data-view="shipping"] .shipping-route-row { grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-1); }
  #view[data-view="shipping"] .shipping-route-row > svg { display: none; }
  #view[data-view="shipping"] .shipping-route-row > span { white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 360px) {
  #view[data-view="shipping"] .shipping-summary-grid .metric {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
  }
}

/* Payments: compact queues and counterparty-first records. */
#view[data-view="payments"] .payment-flow-panel {
  gap: var(--space-3);
  padding: var(--space-3);
  border-color: var(--border);
  border-radius: var(--radius-lg);
}
#view[data-view="payments"] .payment-create-card {
  background: var(--surface-panel);
  border-radius: var(--radius-md);
  height: var(--control-lg);
}
#view[data-view="payments"] .payment-filter-bar {
  grid-template-columns: minmax(160px, 1fr) 120px 150px minmax(220px, .8fr) auto;
  gap: var(--space-2);
  padding: var(--space-3);
}
#view[data-view="payments"] .payment-list-head,
#view[data-view="payments"] .payment-row {
  grid-template-columns: minmax(220px, 1fr) 140px 150px minmax(120px, .45fr) 142px;
  gap: var(--space-3);
  padding-inline: var(--space-3);
}
#view[data-view="payments"] .payment-row {
  padding-block: var(--space-2);
}
#view[data-view="payments"] .payment-row-counterparty {
  margin-bottom: var(--space-1);
  font-size: 14px;
  line-height: 1.5;
}
#view[data-view="payments"] .payment-row-title {
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}
#view[data-view="payments"] .payment-row-title > strong {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
#view[data-view="payments"] .payment-row-purpose {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
#view[data-view="payments"] .payment-row-amount {
  min-width: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
#view[data-view="payments"] .payment-row-amount > span {
  font-size: 11px;
}
#view[data-view="payments"] .payment-row-actions .small-btn {
  min-height: var(--control-md);
  padding-inline: var(--space-2);
  white-space: nowrap;
}
@media (min-width: 781px) and (max-width: 1180px) {
  #view[data-view="payments"] .payment-filter-bar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  }
  #view[data-view="payments"] .payment-query-field { grid-column: span 2; }
  #view[data-view="payments"] .payment-list-head,
  #view[data-view="payments"] .payment-row {
    grid-template-columns: minmax(160px, 1fr) 100px 120px 110px 74px;
    gap: var(--space-2);
  }
  #view[data-view="payments"] .payment-row-actions { flex-wrap: wrap; }
}
@media (max-width: 780px) {
  #view[data-view="payments"] .payment-flow-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }
  #view[data-view="payments"] .payment-flow-head > div:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
  }
  #view[data-view="payments"] .payment-flow-head p { margin: 0; font-size: 11px; }
  #view[data-view="payments"] .payment-create-actions {
    width: 100%;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #view[data-view="payments"] .payment-create-actions:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
  #view[data-view="payments"] .payment-create-copy small { display: none; }
  #view[data-view="payments"] .payment-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    gap: var(--space-2);
    padding: var(--space-2);
  }
  #view[data-view="payments"] .payment-filter-bar .field { min-width: 0; gap: 0; grid-row: auto; }
  #view[data-view="payments"] .payment-filter-field > span { display: none; }
  #view[data-view="payments"] .payment-query-field { grid-column: 1 / -1; }
  #view[data-view="payments"] .payment-filter-bar .payment-type-field { grid-column: 1; }
  #view[data-view="payments"] .payment-filter-bar .payment-status-field { grid-column: 2; }
  #view[data-view="payments"] .payment-filter-bar .payment-date-field { grid-column: 1; }
  #view[data-view="payments"] .payment-filter-actions {
    grid-column: 2;
    grid-row: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    gap: var(--space-1);
    padding: 0;
  }
  #view[data-view="payments"] .payment-filter-actions .small-btn {
    width: 100%;
    min-width: 0;
    min-height: var(--control-md);
    padding: 0 var(--space-1);
    gap: var(--space-1);
    font-size: 12px;
  }
  #view[data-view="payments"] .payment-filter-actions svg { width: 14px; height: 14px; }
  #view[data-view="payments"] .payment-list { border: 0; background: transparent; gap: var(--space-2); overflow: visible; }
  #view[data-view="payments"] .payment-list-head { display: none; }
  #view[data-view="payments"] .payment-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "main amount" "applicant applicant" "status actions";
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-panel);
  }
  #view[data-view="payments"] .payment-row-main { grid-area: main; }
  #view[data-view="payments"] .payment-row-counterparty { white-space: normal; overflow-wrap: anywhere; }
  #view[data-view="payments"] .payment-row-title { flex-wrap: wrap; }
  #view[data-view="payments"] .payment-row-title > strong { flex-basis: 100%; }
  #view[data-view="payments"] .payment-row-applicant {
    grid-area: applicant;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
  }
  #view[data-view="payments"] .payment-row-applicant strong { font-size: 11px; }
  #view[data-view="payments"] .payment-row-status { grid-area: status; justify-self: start; }
  #view[data-view="payments"] .payment-row-status small { font-size: 10px; }
  #view[data-view="payments"] .payment-row-amount { grid-area: amount; align-self: start; text-align: right; }
  #view[data-view="payments"] .payment-row-amount > strong { font-size: 18px; }
  #view[data-view="payments"] .payment-row-amount small { font-size: 11px; }
  #view[data-view="payments"] .payment-row-actions { grid-area: actions; justify-self: end; flex-wrap: wrap; }
}
@media (max-width: 360px) {
  #view[data-view="payments"] .payment-row-amount > strong { font-size: 16px; }
}

/* Supplier ledger: payable-first hierarchy with compact four-action rows. */
#view[data-view="finance"] .finance-ledger-balance-summary.is-supplier {
  grid-template-columns: 1.16fr 1fr 1fr;
  background: #f7faf9;
}

#view[data-view="finance"] .finance-ledger-balance-summary.is-supplier > span:first-child {
  background: #eef8f3;
}

#view[data-view="finance"] .finance-ledger-balance-summary.is-supplier > span:first-child strong {
  color: #196b4b;
  font-size: 15px;
}

#view[data-view="finance"] .supplier-ledger-desktop-identity {
  min-width: 0;
  display: flex;
  gap: 9px;
  align-items: center;
}

#view[data-view="finance"] .supplier-ledger-avatar {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  color: #19704e;
  background: #edf8f3;
  border: 1px solid #d2eadf;
  border-radius: 8px;
}

#view[data-view="finance"] .supplier-ledger-avatar svg {
  width: 15px;
  height: 15px;
}

#view[data-view="finance"] .supplier-ledger-desktop-identity > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

#view[data-view="finance"] .supplier-ledger-desktop-identity strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view[data-view="finance"] .supplier-ledger-desktop-identity small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

#view[data-view="finance"] .supplier-ledger-row {
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

#view[data-view="finance"] .supplier-ledger-row:hover {
  background: #f8fcfa;
  box-shadow: inset 0 1px #dceee5, inset 0 -1px #dceee5;
}

#view[data-view="finance"] .supplier-ledger-row td:nth-child(2),
#view[data-view="finance"] .supplier-ledger-row td:nth-child(3),
#view[data-view="finance"] .supplier-ledger-row td:nth-child(4) {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

#view[data-view="finance"] .mobile-action-label {
  display: none;
}

@media (min-width: 781px) {
  #view[data-view="finance"] .finance-supplier-panel .ledger-card-table th:first-child { width: 21%; }
  #view[data-view="finance"] .finance-supplier-panel .ledger-card-table th:nth-child(2),
  #view[data-view="finance"] .finance-supplier-panel .ledger-card-table th:nth-child(3),
  #view[data-view="finance"] .finance-supplier-panel .ledger-card-table th:nth-child(4) { width: 10%; }
  #view[data-view="finance"] .finance-supplier-panel .ledger-card-table th:nth-child(5) { width: 10%; }
  #view[data-view="finance"] .finance-supplier-panel .ledger-card-table th:nth-child(6) { width: 9%; }
  #view[data-view="finance"] .finance-supplier-panel .ledger-card-table th:last-child { width: 30%; }

  #view[data-view="finance"] .finance-supplier-panel .ledger-action-row {
    flex-wrap: nowrap;
    gap: 5px;
  }

  #view[data-view="finance"] .finance-supplier-panel .ledger-action-row .small-btn {
    min-width: 0;
    padding-inline: 8px;
    font-size: 11.5px;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .finance-supplier-panel .finance-panel-heading p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-supplier {
    min-height: 50px;
    grid-template-columns: 1.16fr 1fr 1fr;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-supplier > span {
    min-height: 50px;
    padding: 6px 7px;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-supplier small {
    gap: 3px;
    font-size: 9.5px;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-supplier small svg {
    width: 11px;
    height: 11px;
  }

  #view[data-view="finance"] .finance-ledger-balance-summary.is-supplier strong,
  #view[data-view="finance"] .finance-ledger-balance-summary.is-supplier > span:first-child strong {
    font-size: 11.5px;
    line-height: 1.2;
  }

  #view[data-view="finance"] .supplier-ledger-desktop-identity,
  #view[data-view="finance"] .finance-supplier-panel .desktop-action-label {
    display: none;
  }

  #view[data-view="finance"] .finance-supplier-panel .mobile-action-label {
    display: inline;
  }

  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-summary-head {
    align-items: center;
    padding: 10px 11px 8px;
    border-bottom: 1px solid var(--border);
  }

  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-summary-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .supplier-ledger-card-status {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    align-items: center;
    min-width: 0;
  }

  #view[data-view="finance"] .supplier-ledger-card-status .status-chip {
    min-width: 0;
    min-height: 24px;
    max-width: 108px;
    padding: 0 7px;
    overflow: hidden;
    border-radius: 999px;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .supplier-ledger-list-balance {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 9px 11px;
  }

  #view[data-view="finance"] .supplier-ledger-balance-total {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  #view[data-view="finance"] .supplier-ledger-balance-total > span {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
  }

  #view[data-view="finance"] .supplier-ledger-balance-total > strong {
    min-width: 0;
    overflow: hidden;
    color: #196b4b;
    font-size: 18px;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view[data-view="finance"] .supplier-ledger-balance-total > strong.danger-text {
    color: var(--danger);
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .supplier-ledger-balance-meta {
    min-width: 0;
    display: grid;
    gap: 4px;
    justify-items: end;
  }

  #view[data-view="finance"] .supplier-ledger-balance-state {
    color: #196b4b;
    font-size: 10.5px;
    font-weight: 800;
  }

  #view[data-view="finance"] .supplier-ledger-balance-state.is-debt {
    color: var(--danger);
  }

  #view[data-view="finance"] .supplier-ledger-balance-state.is-settled {
    color: var(--muted);
  }

  #view[data-view="finance"] .supplier-ledger-balance-meta time {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    color: var(--text-secondary);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
  }

  #view[data-view="finance"] .supplier-ledger-balance-meta time svg {
    width: 12px;
    height: 12px;
  }
}

@media (max-width: 780px) {
  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-balance-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 11px;
    padding: 8px 0;
  }

  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-balance-band > div {
    align-items: start;
    padding: 0 9px 0 0;
    text-align: left;
  }

  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-balance-band > div + div {
    padding-right: 0;
    padding-left: 10px;
  }

  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-balance-band span {
    display: inline-flex;
    gap: 4px;
    align-items: center;
  }

  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-balance-band span svg {
    width: 12px;
    height: 12px;
  }

  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-balance-band strong {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  #view[data-view="finance"] .finance-supplier-panel .mobile-action-cell {
    padding: 7px 9px 9px;
  }

  #view[data-view="finance"] .finance-supplier-panel .ledger-action-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  #view[data-view="finance"] .finance-supplier-panel .ledger-action-row .small-btn {
    min-width: 0;
    min-height: 34px;
    gap: 3px;
    padding: 0 4px;
    font-size: 11px;
  }

  #view[data-view="finance"] .finance-supplier-panel .ledger-action-row .small-btn svg {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
  }
}

@media (max-width: 360px) {
  #view[data-view="finance"] .finance-supplier-panel .finance-ledger-summary-title {
    font-size: 14px;
  }

  #view[data-view="finance"] .supplier-ledger-balance-total > strong {
    font-size: 16px;
  }

  #view[data-view="finance"] .supplier-ledger-card-status .status-chip {
    max-width: 96px;
  }
}

/* Keep ledger sections separated even when the mobile filter form is hidden. */
@media (max-width: 780px) {
  #view[data-view="finance"] :is(.finance-customer-panel, .finance-supplier-panel) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }
}

/* Deal-map clusters retain every address, with bounded popup rows. */
.deal-map-zoom-hint[hidden] { display: none; }
.deal-map-popup { overflow-y: auto; overscroll-behavior: contain; }
.deal-map-popup .deal-map-info-window { width: 100%; max-width: 100%; }
.deal-map-group-list {
  display: grid;
  max-height: min(280px, 36vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.deal-map-group-list > button {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-panel);
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.deal-map-group-list > button:hover,
.deal-map-group-list > button:focus-visible {
  background: var(--brand-soft);
  color: var(--brand);
}

.deal-map-group-list span { min-width: 0; overflow-wrap: anywhere; }
.deal-map-group-list b { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.deal-map-group-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.deal-map-group-actions .small-btn { min-height: 32px; padding: 4px 8px; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .sidebar, .topbar-actions, .mobile-bottom-nav, .order-mobile-action-bar, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .app-shell { display: block; }
  .order-main, .panel, .card { box-shadow: none; }
}

/* Supplier directory: align row dividers across every desktop column. */
@media (min-width: 761px) {
  .finance-directory-modal .supplier-directory-table {
    border-collapse: collapse;
  }
  .finance-directory-modal .supplier-directory-table td {
    display: table-cell;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
  }
  .finance-directory-modal .supplier-directory-table .button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
}

@media (min-width: 761px) {
  .finance-directory-modal .supplier-directory-table .directory-actions-cell .small-btn {
    padding-inline: 7px;
    gap: 5px;
    font-size: 12px;
  }
}

/* Supplier association: clear navigation, aligned identity rows and compact status. */
.supplier-sales-modal { width: min(860px, calc(100vw - 40px)); }
.supplier-sales-modal .modal-header h2 { display:flex; align-items:center; gap:10px; }
.supplier-sales-modal .modal-header h2 svg { width:22px; color:var(--primary); }
.supplier-sales-modal .modal-body { padding:20px; }
.supplier-sales-panel { margin:0; padding:0; border:0; box-shadow:none; min-width:0; }
.supplier-sales-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; }
.supplier-sales-heading h3 { margin:0; font-size:18px; overflow-wrap:anywhere; min-width:0; }
.supplier-sales-heading button { flex-shrink:0; }
.supplier-sales-note { margin:12px 0; padding:10px 12px; background:var(--surface-subtle); border-radius:7px; color:var(--text-secondary); font-size:12px; line-height:1.7; }
.supplier-sales-search { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; margin:16px 0; }
.supplier-sales-rows { border:1px solid var(--border); border-radius:9px; overflow:hidden; }
.supplier-sales-panel .supplier-sales-row { padding:14px 16px; flex-wrap:nowrap; gap:12px; }
.supplier-sales-row:last-child { border-bottom:0; }
.supplier-sales-row > div { display:grid; grid-template-columns:minmax(0,1fr) auto; column-gap:12px; flex:1; align-items:center; }
.supplier-sales-row strong { font-size:14px; }
.supplier-sales-row p { grid-column:1; margin-top:4px; }
.supplier-sales-status { grid-column:2; grid-row:1 / span 2; border-radius:5px; padding:4px 7px; font-size:11px; color:var(--text-secondary); background:var(--surface-subtle); white-space:nowrap; }
.supplier-sales-status.is-linked { color:#087443; background:#eaf7f0; }
.supplier-sales-row > small { color:var(--text-secondary); font-size:12px; text-align:right; }
.supplier-sales-pagination { display:flex; align-items:center; justify-content:flex-end; gap:8px; padding-top:16px; }
.supplier-sales-pagination > span { margin-right:auto; font-size:12px; color:var(--text-secondary); }
@media(max-width:760px) {
 .supplier-sales-modal { width:100%; height:100dvh; max-height:100dvh; border-radius:0; }
 .supplier-sales-modal .modal-body { padding:12px; }
 .supplier-sales-heading { gap:8px; }
 .supplier-sales-heading h3 { font-size:16px; }
 .supplier-sales-panel .supplier-sales-row { padding:12px 10px; gap:8px; }
 .supplier-sales-row > div { column-gap:6px; }
 .supplier-sales-status { grid-column:1; grid-row:auto; justify-self:start; margin-top:6px; }
 .supplier-sales-row > small { max-width:110px; }
 .supplier-sales-pagination { flex-wrap:wrap; }
 .supplier-sales-pagination > span { flex-basis:100%; }
}

.supplier-sales-backdrop { z-index: 180; }
.supplier-sales-modal { height: auto; max-height: min(780px, 90dvh); }
@media(max-width:760px) { .supplier-sales-modal { width:calc(100vw - 20px); max-height:90dvh; border-radius:12px; } }

/* Give each supplier dialog a bounded, reachable scrolling region. */
.supplier-directory-modal { display:flex; flex-direction:column; overflow:hidden; }
.supplier-directory-modal > .modal-header { flex-shrink:0; }
.supplier-directory-modal > .directory-modal-body { min-height:0; flex:1 1 auto; }
.finance-directory-modal.supplier-directory-modal .finance-directory-content {
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}
.supplier-sales-modal > .directory-modal-body {
  display:block;
  overflow-y:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  padding:12px 16px;
}
.supplier-sales-modal .supplier-sales-heading { margin-bottom:8px; }
.supplier-sales-modal .supplier-sales-heading h3 { font-size:16px; }
.supplier-sales-modal .supplier-sales-note { margin:8px 0; padding:7px 10px; line-height:1.5; }
.supplier-sales-modal .supplier-sales-search { margin:10px 0; }
.supplier-sales-modal .supplier-sales-row { padding:9px 12px; }
.supplier-sales-modal .supplier-sales-row p { margin-top:2px; font-size:11px; }
.supplier-sales-modal .supplier-sales-pagination { padding-top:10px; }
@media(max-width:780px) {
 .finance-directory-modal.supplier-directory-modal > .directory-modal-body { overflow-y:auto; display:block; }
 .finance-directory-modal.supplier-directory-modal .finance-directory-content { overflow:visible; max-height:none; margin:10px 0; }
 .supplier-sales-modal > .directory-modal-body { padding:10px; }
 .supplier-sales-modal .supplier-sales-status { grid-column:2; grid-row:1 / span 2; margin:0; }
 .supplier-sales-modal .supplier-sales-row { padding:9px 8px; gap:7px; }
 .supplier-sales-modal .supplier-sales-row button { padding-inline:7px; gap:4px; font-size:12px; }
}

/* Multi-column association cards retain the existing per-user actions. */
.supplier-sales-modal .supplier-sales-user-grid {
 display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px;
 border:0; border-radius:0; overflow:visible;
}
.supplier-sales-modal .supplier-sales-user-grid .supplier-sales-row {
 display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center;
 gap:6px; padding:10px; border:1px solid var(--border); border-radius:8px;
}
.supplier-sales-modal .supplier-sales-user-grid .supplier-sales-row > div { display:flex; flex-wrap:wrap; gap:3px 6px; }
.supplier-sales-modal .supplier-sales-user-grid .supplier-sales-row strong { width:100%; font-size:13px; }
.supplier-sales-modal .supplier-sales-user-grid .supplier-sales-row p { margin:0; }
.supplier-sales-modal .supplier-sales-user-grid .supplier-sales-status { margin:0; padding:2px 4px; font-size:10px; }
.supplier-sales-modal .supplier-sales-user-grid .small-btn { padding:5px 7px; gap:4px; font-size:11px; }
.supplier-sales-modal .supplier-sales-user-grid > p { grid-column:1 / -1; }
@media(max-width:760px) {
 .supplier-sales-modal .supplier-sales-user-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
 .supplier-sales-modal .supplier-sales-user-grid .supplier-sales-row { grid-template-columns:minmax(0,1fr); padding:8px; }
 .supplier-sales-modal .supplier-sales-user-grid .small-btn { width:100%; justify-content:center; min-height:30px; }
}

/* Ledger details use the available desktop height for transaction rows. */
@media (min-width: 781px) {
 .modal-backdrop > .customer-ledger-detail-modal,
 .modal-backdrop > .supplier-ledger-detail-modal {
  height:calc(100dvh - 32px);
  max-height:calc(100dvh - 32px);
 }
 .customer-ledger-detail-modal > .modal-body,
 .supplier-ledger-detail-modal > .modal-body { min-height:0; flex:1 1 auto; }
}
