:root {
  --ink: #12213a;
  --muted: #657084;
  --line: #dbe2ec;
  --soft: #f5f7fa;
  --panel: #ffffff;
  --nav: #082243;
  --nav-2: #103b68;
  --accent: #087f6f;
  --accent-2: #0a5c91;
  --danger: #c0392b;
  --warning: #d4a017;
  --shadow: 0 14px 40px rgba(18, 33, 58, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background: #eef2f6;
  font-family: Aptos, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.check-inline {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
}

.check-inline input {
  width: 16px;
}

button {
  cursor: pointer;
}

/* ========= Dialog Overlay ========= */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialog-overlay.hidden { display: none; }
.dialog-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px 20px;
  max-width: 420px;
  width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.dialog-box p { margin: 0 0 22px; font-size: 15px; line-height: 1.5; color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ========= Toast Notification ========= */
.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1100;
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: opacity 0.25s;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }

/* ========= Hidden utility ========= */
.hidden { display: none !important; }

/* ========= App Shell ========= */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  width: 190px;
  background: linear-gradient(180deg, var(--nav), #06162d);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #0f75bd;
  font-weight: 800;
}

.brand strong,
.operator strong {
  display: block;
  font-size: 15px;
}

.brand span,
.operator span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  margin-top: 3px;
}

.side-nav {
  display: grid;
  gap: 6px;
  margin-top: 24px;
}

.nav-item {
  border: 0;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-documents {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  gap: 10px;
  min-height: 0;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-section-title strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-section-title button {
  border: 0;
  padding: 4px 6px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.1);
  font-size: 10px;
  font-weight: 700;
}

.sidebar-documents input {
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
}

.sidebar-documents input::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

.sidebar-documents .saved-documents-list {
  max-height: 36vh;
  overflow: auto;
  padding-right: 2px;
}

.sidebar-documents .saved-document-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 8px;
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-documents .saved-document-main {
  grid-column: 1 / -1;
}

.sidebar-documents .saved-document-main strong {
  color: #fff;
  font-size: 12px;
}

.sidebar-documents .saved-document-main span {
  color: rgba(255, 255, 255, 0.64);
  font-size: 10px;
}

.sidebar-documents .saved-document-row .compact {
  min-height: 28px;
  padding: 5px 8px;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  font-size: 11px;
}

.sidebar-documents .saved-document-row .delete-row {
  justify-self: end;
  min-height: 28px;
  padding: 5px 8px;
  color: #ffb4a9;
}

.sidebar-documents .saved-documents-empty {
  color: rgba(255, 255, 255, 0.62);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.operator {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.workspace {
  flex: 1;
  min-width: 0;
}

.workspace-view {
  min-width: 0;
}

.documents-view {
  padding: 18px;
}

.documents-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(18, 33, 58, 0.02);
}

.documents-page-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.15;
}

.documents-page-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.documents-page-tools {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.documents-page-tools input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

.documents-list {
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.documents-list .saved-document-row {
  padding: 14px 16px;
  background: #fbfcfe;
}

.documents-list .saved-document-main strong {
  font-size: 15px;
}

.documents-list .saved-document-main span {
  font-size: 12px;
}

/* ========= Topbar ========= */
.topbar {
  min-height: 96px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.control-group {
  display: grid;
  gap: 7px;
}

.control-group.wide {
  min-width: 360px;
}

.control-group > span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-width: 68px;
  border: 0;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  font-size: 13px;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented .selected {
  background: var(--nav);
  color: #fff;
}

.actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: end;
}

.primary,
.ghost {
  border-radius: 7px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}

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

.compact {
  padding: 8px 12px;
}

/* ========= Content Grid ========= */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(460px, 500px);
  gap: 16px;
  padding: 16px;
}

.editor {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 0 rgba(18, 33, 58, 0.02);
}

.panel-title {
  margin-bottom: 14px;
}

.panel-title.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-title h2 {
  margin: 0;
  font-size: 15px;
}

.panel-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.document-info-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: end;
}

.document-info-grid .doc-title-field,
.document-info-grid .payment-terms-field {
  grid-column: auto;
}

.document-info-grid .inline-control-field {
  display: grid;
  grid-template-columns: max-content minmax(112px, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 6px;
}

.document-info-grid .inline-control-field > select {
  min-width: 0;
  width: 100%;
}

.document-info-grid .payment-terms-field {
  grid-column: span 2;
  grid-template-columns: max-content minmax(180px, 280px) 120px 66px;
  justify-content: start;
}

.document-info-grid .payment-terms-field > select {
  min-width: 0;
}

.document-info-grid .payment-status-field {
  grid-column: span 2;
  grid-template-columns: max-content minmax(130px, 190px) 66px;
  justify-content: start;
}

.document-info-grid .page-number-field {
  grid-template-columns: max-content minmax(130px, 190px) 32px;
  justify-content: start;
}

.document-info-grid .incoterms-field {
  grid-template-columns: minmax(140px, 190px) 66px;
  grid-template-areas:
    "label label"
    "control show";
  justify-content: start;
}

.document-info-grid .incoterms-field .inline-field-label {
  grid-area: label;
}

.document-info-grid .incoterms-field > select {
  grid-area: control;
}

.document-info-grid .incoterms-field .inline-show {
  grid-area: show;
}

.inline-show {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.inline-show input {
  width: 14px;
  height: 14px;
}

.inline-field-action {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}

.provider-grid .provider-inline-field {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 6px;
}

.provider-grid .provider-inline-field > input,
.provider-grid .provider-inline-field > textarea {
  min-width: 0;
}

.provider-grid .provider-address-field {
  align-items: start;
}

.provider-grid .provider-address-field .inline-show {
  padding-top: 12px;
}

.form-grid.provider-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.form-grid .span-three {
  grid-column: span 3;
}

.form-grid .span-two {
  grid-column: span 2;
}

.check-row-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

input[type="number"] {
  text-align: center;
}

textarea {
  min-height: 64px;
  resize: vertical;
}

.large-text {
  min-height: 90px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  text-align: left;
}

.edit-table td input,
.edit-table td textarea,
.edit-table td select {
  border: 0;
  padding: 4px;
  background: transparent;
}

.edit-table textarea {
  min-height: 42px;
}

.small {
  width: 76px;
}

.money {
  width: 116px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.icon-col {
  width: 44px;
}

.image-col {
  width: 130px;
}

.image-toggle {
  margin: 0 0 10px;
}

.line-column-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  margin: 0 0 12px;
}

.line-column-controls .check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.line-column-controls .check-inline span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.line-image-editor {
  display: grid;
  gap: 6px;
  align-items: center;
}

.line-image-preview {
  width: 88px;
  min-height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
}

.line-image-preview img {
  width: 72px;
  height: 54px;
  object-fit: contain;
}

.line-image-preview span {
  color: var(--muted);
  font-size: 11px;
}

.line-image-editor input[type="file"] {
  max-width: 120px;
  font-size: 10px;
}

.line-image-editor input[data-field="imageNote"] {
  min-height: 32px;
  max-width: 128px;
  padding: 6px 8px;
  font-size: 11px;
}

.bank-attachments-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.attachment-panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.attachment-editor-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.attachment-editor-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
}

.attachment-editor-row img {
  width: 72px;
  height: 54px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #fff;
}

.document-attachment-row {
  grid-template-columns: 72px minmax(0, 1fr) 58px 32px;
}

.attachment-file-badge {
  width: 72px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #b42318;
  font-size: 13px;
  font-weight: 900;
}

.attachment-type-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.delete-row {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 5px 7px;
  font-weight: 800;
}

/* ========= Empty hint ========= */
.empty-hint {
  margin: 18px 0 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

/* ========= Fees ========= */
.fee-list {
  display: grid;
  gap: 14px;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(220px, 1fr) 132px 104px 34px;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
  max-width: 760px;
}

.fee-control-row,
.conversion-row,
.fee-item-row {
  min-height: 48px;
}

.fee-control-row {
  width: 100%;
  max-width: none;
  padding: 10px 0;
}

.fee-control-row > span,
.conversion-row > span {
  min-width: 0;
  color: var(--ink);
  line-height: 1.25;
}

.check-row select {
  min-width: 0;
}

.check-row input[type="number"] {
  min-width: 0;
}

.check-row input[type="number"],
.fee-item-row input[type="number"],
.edit-table input[type="number"] {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  justify-self: center;
}

.check-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

#settlementCommissionRow {
  grid-template-columns: minmax(220px, 1fr) minmax(132px, 176px) minmax(104px, 138px) 38px;
  max-width: none;
}

#settlementCommissionRow select {
  min-width: 0;
}

.fee-items {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  max-width: none;
}

.fee-items-head,
.fee-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.fee-items-head {
  min-height: 42px;
}

.fee-items-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.fee-items-body {
  display: grid;
  gap: 8px;
}

.fee-item-row {
  grid-template-columns: 38px minmax(180px, 1fr) minmax(104px, 156px) 34px;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfcfe;
}

.fee-item-row input {
  min-width: 0;
}

.fee-item-row .delete-row {
  width: 30px;
  height: 30px;
  justify-self: center;
  border-radius: 7px;
  font-size: 16px;
  line-height: 1;
}

.fee-item-row .delete-row:hover {
  background: #fff0ed;
}

.fee-show {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fee-show input {
  width: 16px;
  height: 16px;
}

.cny-total-panel {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  max-width: none;
}

.cny-total-panel .check-row {
  max-width: none;
}

.conversion-row {
  grid-template-columns: minmax(170px, 1fr) minmax(132px, 180px) minmax(126px, 186px) minmax(76px, auto);
  padding: 10px 0;
}

.bank-profile-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 48px;
}

.client-parse-field {
  display: grid;
  gap: 8px;
}

.client-parse-field textarea {
  min-height: 86px;
}

.client-parse-field button {
  justify-self: start;
}

.settlement-check {
  align-self: end;
  min-height: 48px;
}

.remark-options {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.remark-options-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.remark-clause-list {
  display: grid;
  gap: 8px;
}

.remark-clause-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.remark-clause-row label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.remark-clause-row input {
  margin-top: 2px;
}

.remarks-items-editor {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.preset-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(190px, 280px) auto;
  gap: 8px;
  align-items: center;
}

.preset-row input,
.preset-row select {
  min-width: 0;
  width: 100%;
}

.remark-item-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 58px 34px;
  align-items: center;
  gap: 8px;
}

.remark-item-row[draggable="true"] {
  cursor: grab;
}

.remark-item-number {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.remark-item-row input {
  min-width: 0;
}

.drag-handle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

/* ========= Saved Documents ========= */
.saved-documents-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.saved-documents-list {
  display: grid;
  gap: 8px;
}

.saved-document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.saved-document-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.saved-document-main strong {
  color: var(--ink);
  font-size: 13px;
}

.saved-document-main span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.saved-documents-empty {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  font-size: 12px;
}

/* ========= Summary ========= */
.summary-list {
  margin: 2px 0 0;
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.summary-list > div:not(.summary-detail-group),
.summary-detail-group > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, auto);
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  gap: 18px;
}

.summary-detail-group {
  display: contents;
}

.summary-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-list dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.summary-list .total {
  border-bottom: 0;
  min-height: 52px;
  margin-top: 0;
  padding: 0 16px;
  background: #f1faf8;
  box-shadow: inset 4px 0 0 var(--accent);
}

.summary-list .total dd {
  color: var(--accent);
  font-size: 22px;
}

.summary-list .total dt {
  color: #334155;
  font-weight: 800;
}

/* ========= Preview ========= */
.preview-column {
  position: sticky;
  top: 14px;
  align-self: start;
  display: grid;
  gap: 10px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.a4 {
  width: 100%;
  min-height: 735px;
  position: relative;
  background: #fff;
  border: 1px solid #d6dde8;
  box-shadow: var(--shadow);
  padding: 30px 30px 72px;
  font-family: Aptos, Inter, Arial, Helvetica, sans-serif;
  color: #172033;
}

.doc-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.56fr) minmax(0, 0.44fr);
  gap: 10px;
  align-items: start;
  padding-bottom: 26px;
  border-bottom: 2px solid #13233b;
  margin-bottom: 18px;
}

.doc-brand-block {
  display: grid;
  gap: 1px;
  justify-items: start;
  min-width: 0;
  overflow: hidden;
  padding-top: 4px;
  transform: translateY(-28px);
}

.doc-brand-block > div {
  min-width: 0;
  overflow: hidden;
}

.doc-logo {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #13233b;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0;
}

.doc-logo-img {
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
}

.doc-logo-img.round {
  width: 88px;
  height: 88px;
  border-radius: 50%;
}

.doc-logo-img.wide {
  width: 140px;
  height: 80px;
}

.doc-kicker {
  margin: 0 0 4px;
  color: #13233b;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-brand-block h1 {
  margin: 0 0 8px;
  color: #111827;
  font-size: 22px;
  line-height: 1.14;
  font-weight: 900;
  white-space: nowrap;
  transform: scaleX(0.9);
  transform-origin: left center;
  overflow-wrap: normal;
  word-break: normal;
}

.doc-brand-block p,
.party p,
.doc-remarks p,
.amount-words {
  margin: 2px 0;
  font-size: 10px;
  line-height: 1.45;
  color: #4b5565;
  overflow-wrap: anywhere;
}

.doc-brand-block p {
  line-height: 1.58;
}

.doc-title-block {
  display: grid;
  align-content: center;
  justify-items: stretch;
  justify-self: end;
  width: 100%;
  min-height: 116px;
  padding: 0;
  background: #f3f5f6;
  border: 1px solid #d7dde1;
  border-radius: 8px;
  text-align: center;
  box-sizing: border-box;
  transform: translateY(-6px);
}

.doc-title-block p,
.doc-title-block span {
  margin: 0;
  color: #516071;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-title-block h2 {
  margin: 0;
  color: #111827;
  font-size: 40px;
  line-height: 1.38;
  letter-spacing: 0;
  text-transform: uppercase;
  overflow-wrap: normal;
  word-break: keep-all;
  text-align: center;
  justify-self: center;
  width: max-content;
  transform: translateX(-6px) scaleX(0.94);
  transform-origin: center;
  max-width: none;
}

.doc-title-block .doc-title-line {
  display: block;
  width: max-content;
  margin: 0 auto;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  line-height: 1.45;
}

.doc-meta-grid {
  display: grid;
  grid-template-columns: repeat(var(--meta-cols, 4), minmax(0, 1fr));
  border: 1px solid #d5dce7;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
}

.doc-meta-grid div {
  min-width: 0;
  padding: 9px 10px;
  border-right: 1px solid #d5dce7;
  background: #fff;
}

.doc-meta-grid div:last-child {
  border-right: 0;
}

.doc-meta-grid .wide {
  grid-column: 1 / -1;
  border-top: 1px solid #d5dce7;
}

.doc-meta-grid span {
  display: block;
  color: #697586;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-meta-grid strong {
  display: block;
  margin-top: 4px;
  color: #162033;
  font-size: 10px;
  line-height: 1.35;
  word-break: break-word;
}

.parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.doc-order-reference {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: -2px 0 10px;
  padding: 7px 10px;
  border: 1px solid #d5dce7;
  border-radius: 6px;
  background: #fbfcfe;
}

.doc-order-reference span {
  color: #64748b;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-order-reference strong {
  color: #111827;
  font-size: 10px;
}

.party {
  min-width: 0;
  padding: 11px 14px 12px;
  border: 1px solid #d5dce7;
  border-radius: 8px;
  background: #fbfcfe;
}

.party h3,
.doc-remarks h3 {
  margin: 0 0 7px;
  color: #13233b;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.party h4 {
  margin: 0 0 6px;
  color: #111827;
  font-size: 12px;
  line-height: 1.25;
}

.doc-table {
  margin-top: 0;
  border: 1px solid #d5dce7;
  border-radius: 8px;
  overflow: hidden;
  table-layout: fixed;
}

.doc-table th:nth-child(1),
.doc-table td:nth-child(1) {
  width: 28px;
  text-align: center;
}

.doc-table th:nth-child(3),
.doc-table td:nth-child(3) {
  width: 40px;
  text-align: center;
}

.doc-table th:nth-child(4),
.doc-table td:nth-child(4) {
  width: 34px;
  text-align: center;
}

.doc-table th:nth-child(6),
.doc-table td:nth-child(6) {
  width: 88px;
  text-align: center;
}

.doc-table th:nth-child(5),
.doc-table td:nth-child(5) {
  width: 82px;
  text-align: center;
}

.doc-table.translation-table th:nth-child(3),
.doc-table.translation-table td:nth-child(3) {
  width: 46px;
}

.doc-table.translation-table th:nth-child(4),
.doc-table.translation-table td:nth-child(4) {
  width: 122px;
  text-align: center;
}

.doc-table.translation-table th:nth-child(5),
.doc-table.translation-table td:nth-child(5) {
  width: 108px;
  text-align: center;
}

.doc-table.settlement-table th:nth-child(3),
.doc-table.settlement-table td:nth-child(3) {
  width: 66px;
}

.doc-table.settlement-table th:nth-child(4),
.doc-table.settlement-table td:nth-child(4) {
  width: 48px;
}

.doc-table.settlement-table th:nth-child(5),
.doc-table.settlement-table td:nth-child(5) {
  width: 112px;
}

.doc-table.settlement-table th:nth-child(6),
.doc-table.settlement-table td:nth-child(6) {
  width: 128px;
}

.doc-table.has-product-images th:nth-child(3),
.doc-table.has-product-images td:nth-child(3) {
  width: 78px;
}

.doc-table.has-product-images th:nth-child(4),
.doc-table.has-product-images td:nth-child(4),
.doc-table.has-product-images th:nth-child(5),
.doc-table.has-product-images td:nth-child(5) {
  width: 48px;
}

.doc-table.has-product-images th:nth-child(6),
.doc-table.has-product-images td:nth-child(6) {
  width: 96px;
}

.doc-table.has-product-images th:nth-child(7),
.doc-table.has-product-images td:nth-child(7) {
  width: 108px;
}

.doc-table th,
.doc-table td {
  border-right: 0;
  border-bottom: 1px solid #e5eaf1;
  padding: 9px 10px;
  font-size: 10px;
  line-height: 1.35;
  word-break: break-word;
  vertical-align: top;
}

.doc-table th:nth-child(2),
.doc-table td:nth-child(2) {
  padding-left: 6px;
  padding-right: 6px;
  text-align: left !important;
}

.doc-table th:nth-child(1),
.doc-table td:nth-child(1),
.doc-table th:nth-child(3),
.doc-table td:nth-child(3),
.doc-table th:nth-child(4),
.doc-table td:nth-child(4),
.doc-table th:nth-child(5),
.doc-table td:nth-child(5),
.doc-table th:nth-child(6),
.doc-table td:nth-child(6) {
  white-space: nowrap;
}

.doc-table tbody tr:nth-child(even) td {
  background: #fbfcfe;
}

.doc-table th {
  background: #1f2937;
  color: #fff;
  padding: 8px 7px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-table.translation-table th {
  padding-left: 6px;
  padding-right: 6px;
  font-size: 7px;
}

.doc-table.settlement-table th {
  white-space: normal;
  line-height: 1.18;
}

.doc-table .right,
.totals-table .right {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.doc-table .shipped-qty-value {
  font-weight: 800;
}

.doc-table th:nth-child(3),
.doc-table td:nth-child(3),
.doc-table th:nth-child(4),
.doc-table td:nth-child(4),
.doc-table th:nth-child(5),
.doc-table td:nth-child(5),
.doc-table th:nth-child(6),
.doc-table td:nth-child(6) {
  text-align: center;
}

.doc-table th.right,
.doc-table td.right,
.doc-table th:last-child,
.doc-table td:last-child {
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

.doc-table th.right,
.doc-table td.right {
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}

.doc-table th.amount-cell,
.doc-table td.amount-cell {
  text-align: center !important;
  vertical-align: middle;
  padding-left: 6px;
  padding-right: 6px;
}

.doc-table th.index-col,
.doc-table td.index-col {
  width: 28px;
  text-align: center !important;
}

.doc-table th.picture-col,
.doc-table td.picture-col {
  width: 78px;
  text-align: center !important;
}

.doc-table th.qty-col,
.doc-table td.qty-col {
  width: 52px;
  text-align: center !important;
}

.doc-table th.unit-col,
.doc-table td.unit-col {
  width: 48px;
  text-align: center !important;
}

.doc-table th.price-col,
.doc-table td.price-col {
  width: 96px;
}

.doc-table th.total-col,
.doc-table td.total-col {
  width: 112px;
}

.doc-table th.description-col,
.doc-table td.description-col {
  text-align: left !important;
}

.doc-table.settlement-table th,
.doc-table.settlement-table td,
.doc-table.settlement-table th.right,
.doc-table.settlement-table td.right,
.doc-table.settlement-table th.amount-cell,
.doc-table.settlement-table td.amount-cell,
.doc-table.settlement-table th:last-child,
.doc-table.settlement-table td:last-child {
  text-align: center !important;
  vertical-align: middle;
  padding-left: 6px;
  padding-right: 6px;
}

.doc-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: 20px;
  align-items: start;
  margin-top: 12px;
}

.settlement-doc-bottom {
  grid-template-columns: minmax(0, 1fr) minmax(0, 430px);
}

.amount-words {
  display: inline-block;
  max-width: 500px;
  width: 66.666%;
  margin-top: 8px;
  padding: 8px 0 10px;
  border-bottom: 1px solid #d5dce7;
  color: #111827;
  font-size: 10px;
  line-height: 1.28;
}

.amount-words b {
  display: block;
  margin-bottom: 5px;
  color: #486381;
  font-size: 10px;
}

.totals-table {
  justify-self: end;
  width: 100%;
  max-width: 370px;
  table-layout: fixed;
  box-sizing: border-box;
  border: 1px solid #d5dce7;
  border-radius: 8px;
  overflow: hidden;
  transform: translateY(-4px);
}

.totals-table td {
  height: 32px;
  padding: 0 12px;
  font-size: 10px;
  border-bottom: 1px solid #e5eaf1;
  vertical-align: middle;
}

.totals-table td:first-child {
  white-space: normal;
  width: 60%;
  padding-left: 8px;
  padding-right: 8px;
}

.totals-table td:last-child {
  width: 40%;
  text-align: right;
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 22px;
  font-variant-numeric: tabular-nums;
}

.settlement-totals-table {
  max-width: 430px;
}

.settlement-totals-table td:first-child {
  width: 68%;
}

.settlement-totals-table td:last-child {
  width: 32%;
}

.linked-invoice {
  display: inline-block;
  margin-top: 3px;
  color: #64748b;
  font-size: 8px;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.totals-table tr:last-child td {
  border-bottom: 0;
}

.totals-table .emphasis-row td {
  font-weight: 800;
}

.totals-table .grand td {
  background: #1f2937;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  vertical-align: middle;
}

.totals-table .grand .right {
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 22px;
  text-align: right;
}

.dual-currency-total {
  display: inline-grid;
  gap: 2px;
  justify-items: end;
  line-height: 1.15;
}

.dual-currency-total strong,
.dual-currency-total span {
  display: block;
  white-space: nowrap;
}

.doc-totals-block {
  justify-self: end;
  width: 100%;
  max-width: 340px;
}

.doc-remarks {
  margin-top: 12px;
  border-top: 0;
  padding-top: 12px;
}

.doc-remark-list {
  margin: 0;
  padding-left: 16px;
  color: #344257;
  font-size: 10px;
  line-height: 1.45;
}

.doc-remark-list li {
  margin: 2px 0;
  padding-left: 2px;
}

/* ========= Invoice extras ========= */
.doc-invoice-bank {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #d5dce7;
  border-radius: 8px;
  background: #fbfcfe;
  font-size: 8.5px;
  display: grid;
  gap: 1px;
}
.doc-invoice-bank h3 {
  margin: 0 0 6px;
  color: #13233b;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}
.doc-invoice-bank p {
  margin: 1px 0;
  line-height: 1.35;
}

.doc-receiving-bank {
  margin-top: 12px;
  border: 1px solid #aeb8c7;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}

.doc-receiving-bank h3 {
  margin: 0;
  padding: 8px 12px;
  background: #1f2937;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-bank-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.85fr) 78px;
  gap: 18px;
  align-items: center;
  min-height: 102px;
  padding: 12px 14px 10px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.doc-bank-col {
  min-width: 0;
}

.doc-bank-col + .doc-bank-col {
  padding-left: 18px;
  border-left: 1px solid #aeb8c7;
}

.doc-bank-col p {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  margin: 0 0 5px;
  color: #13233b;
  font-size: 8px;
  line-height: 1.28;
}

.doc-bank-col b {
  font-weight: 900;
}

.doc-bank-col span {
  font-weight: 500;
}

.doc-bank-icon {
  justify-self: center;
  color: #13233b;
}

.doc-bank-icon svg {
  display: block;
  width: 58px;
  height: 58px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.doc-bank-thanks {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 4px 150px 12px;
  color: #486381;
  font-size: 10px;
  font-weight: 800;
}

.doc-bank-thanks span {
  height: 1px;
  background: #aeb8c7;
}

.doc-page-thanks {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 0 150px;
  color: #486381;
  font-size: 10px;
  font-weight: 800;
}

.doc-page-thanks span {
  height: 1px;
  background: #aeb8c7;
}

.doc-payment-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.doc-payment-status.paid { background: #d4edda; color: #155724; }
.doc-payment-status.partial { background: #fff3cd; color: #856404; }
.doc-payment-status.unpaid { background: #f8f9fa; color: #6c757d; }
.doc-payment-status.overdue { background: #f8d7da; color: #721c24; }

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

/* ========= Modern document layout variant ========= */
.doc-letterhead {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 2px 0 16px;
  margin-bottom: 20px;
  border-bottom: 2px solid #d5dce7;
}

.doc-letterhead-logo {
  min-height: 64px;
  display: flex;
  align-items: center;
  padding-right: 18px;
  border-right: 1px solid #c8d1de;
}

.doc-letterhead-logo .doc-logo-img {
  width: 210px;
  height: 62px;
  object-fit: contain;
  object-position: left center;
  transform: none;
}

.doc-letterhead-logo .doc-logo-img.round {
  width: 72px;
  height: 72px;
}

.doc-letterhead-name {
  min-height: 64px;
  display: flex;
  align-items: center;
  padding-left: 16px;
}

.doc-letterhead-name h1 {
  margin: 0;
  color: #111827;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 900;
}

.doc-modern-header {
  display: grid;
  grid-template-columns: minmax(0, 0.58fr) 260px minmax(0, 0.12fr);
  align-items: start;
  gap: 18px;
  min-height: 72px;
  padding-bottom: 16px;
  margin-top: 12px;
  margin-bottom: 28px;
  border-bottom: 0;
}

.doc-modern-title p {
  margin: 0;
  color: #13233b;
  font-size: 36px;
  line-height: 1.05;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
  display: inline-block;
  white-space: nowrap;
}

.doc-modern-title.is-long-title p {
  font-size: 31px;
}

.doc-modern-title.is-short-title p {
  font-size: 36px;
}

.doc-modern-title h1 {
  margin: 0;
  color: #111827;
  font-size: 36px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.doc-modern-meta-table {
  width: 100%;
  grid-column: 2;
  transform: translateX(128px);
  border-collapse: collapse;
  table-layout: fixed;
  color: #13233b;
  font-size: 10px;
  font-weight: 800;
}

.doc-modern-meta-table th,
.doc-modern-meta-table td {
  height: 34px;
  border: 1px solid #aeb8c7;
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.doc-modern-meta-table th {
  width: 118px;
  background: #fff;
  text-transform: uppercase;
  line-height: 1;
}

.doc-modern-meta-table td {
  background: #fff;
  font-weight: 900;
  line-height: 1;
}

.doc-modern-meta-table tr:first-child td {
  background: #1f2937;
  color: #fff;
}

.doc-payment-strip {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 4px 0 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid #d5dce7;
}

.doc-payment-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid #486381;
  border-radius: 6px;
  color: #486381;
  font-size: 13px;
  font-weight: 900;
}

.doc-payment-strip h3 {
  margin: 0 0 5px;
  color: #486381;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-payment-strip p {
  margin: 0;
  color: #111827;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 700;
}

.doc-parties-modern {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 0;
}

.doc-parties-modern .party {
  padding: 0 34px 0 0;
}

.doc-parties-modern .party + .party {
  padding: 0 0 0 34px;
  border-left: 1px solid #d5dce7;
}

.party {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.party h3::after {
  content: "";
  display: block;
  width: 42px;
  height: 2px;
  margin-top: 7px;
  background: #13233b;
}

.party h3 {
  color: #486381;
  font-size: 12px;
  margin-bottom: 12px;
}

.party h4 {
  font-size: 17px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.party p {
  font-size: 12px;
  line-height: 1.45;
}

.doc-info-strip {
  margin: 14px 0 22px;
  padding: 14px 0 8px;
  border-top: 1px solid #aeb8c7;
  border-bottom: 0;
}

.doc-info-strip.has-payment {
  display: grid;
  align-items: stretch;
}

.doc-info-strip.has-payment.facts-1 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.doc-info-strip.has-payment.facts-2 {
  grid-template-columns: max-content max-content minmax(0, 1fr);
}

.doc-info-strip.has-payment.facts-3 {
  grid-template-columns: max-content max-content max-content minmax(0, 1fr);
}

.doc-info-strip.has-payment.facts-4 {
  grid-template-columns: max-content max-content max-content max-content minmax(0, 1fr);
}

.doc-info-strip.compact {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}

.doc-info-strip div {
  min-height: 42px;
  padding: 0 12px;
  border-right: 0;
  position: relative;
}

.doc-info-strip.has-payment .doc-info-fact {
  min-width: 0;
}

.doc-info-strip div::after {
  content: "";
  position: absolute;
  right: 0;
  top: 6px;
  width: 1px;
  height: 28px;
  background: #aeb8c7;
}

.doc-info-strip div:first-child {
  padding-left: 0;
}

.doc-info-strip div:last-child {
  padding-right: 0;
}

.doc-info-strip div:last-child::after {
  display: none;
}

.doc-info-strip span {
  display: block;
  margin-bottom: 7px;
  color: #13233b;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1.15;
}

.doc-info-strip strong {
  display: block;
  color: #13233b;
  font-size: 10px;
  line-height: 1.28;
  font-weight: 800;
  word-break: normal;
  overflow-wrap: anywhere;
}

.doc-info-payment strong {
  overflow-wrap: normal;
  max-width: 100%;
}

.doc-facts-panel {
  padding: 0 0 0 24px;
  border: 0;
  border-left: 2px solid #d5dce7;
  border-radius: 0;
  background: transparent;
}

.doc-facts-panel div {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 0 0 9px;
  margin-bottom: 9px;
  border-bottom: 1px solid #dbe2ec;
}

.doc-facts-panel div:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.doc-facts-panel span {
  display: block;
  margin-bottom: 0;
  color: #486381;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-facts-panel strong {
  display: block;
  color: #111827;
  font-size: 10px;
  line-height: 1.35;
  font-weight: 800;
}

.doc-order-reference {
  margin: -8px 0 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.doc-order-reference span {
  color: #486381;
  font-size: 10px;
}

.doc-order-reference strong {
  font-size: 11px;
}

.doc-table {
  border: 0;
  border-radius: 0;
}

.doc-table th {
  background: #1f2937;
  height: 32px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 9px;
  text-align: center;
  vertical-align: middle;
}

.doc-table td {
  height: 32px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 11px;
  text-align: center;
  vertical-align: middle;
}

.doc-product-image-cell figure {
  position: relative;
  width: 78px;
  min-height: 60px;
  margin: 0 auto;
}

.doc-product-image-cell img {
  display: block;
  width: 78px;
  max-height: 60px;
  margin: 0 auto;
  object-fit: contain;
}

.doc-product-image-cell figcaption {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  padding: 2px 3px;
  color: #000;
  background: rgba(255, 255, 255, 0.78);
  font-size: 7px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.doc-bank-attachments {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.doc-bank-attachments.layout-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.doc-bank-attachments.layout-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.doc-bank-attachments figure {
  margin: 0;
  break-inside: avoid;
  page-break-inside: avoid;
  border: 1px solid #d5dce7;
  padding: 8px;
  background: #fff;
}

.doc-bank-attachments.layout-2 figure {
  min-height: 210px;
}

.doc-bank-attachments.layout-4 figure {
  min-height: 128px;
}

.doc-bank-attachments figcaption {
  margin: 0 0 6px;
  color: #111827;
  font-size: 11px;
  line-height: 1.3;
  font-weight: 800;
}

.doc-bank-attachments img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.doc-bank-attachments.layout-4 img {
  max-height: 125px;
}

.doc-attachments {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.doc-attachment {
  box-sizing: border-box;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #d5dce7;
  background: #fff;
  padding: 12px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.doc-attachment h3 {
  margin: 0;
  color: #13233b;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
}

.doc-attachment h4 {
  margin: 0;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.doc-attachment-media {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.doc-attachment-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.doc-attachment-pdf {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: 0;
}

.doc-attachment-pdf-print {
  width: 100%;
  height: 100%;
  min-height: 120mm;
  display: grid;
  place-content: center;
  gap: 8px;
  border: 1px solid #d5dce7;
  color: #13233b;
  text-align: center;
}

.doc-attachment-pdf-print strong {
  font-size: 20px;
  font-weight: 900;
}

.doc-attachment-pdf-print span {
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

@media print {
  .doc-bank-attachments {
    break-before: page;
    page-break-before: always;
    padding-top: 0;
  }

  .doc-bank-attachments figure {
    box-sizing: border-box;
  }

  .doc-bank-attachments.layout-2 figure:nth-child(n + 3),
  .doc-bank-attachments.layout-4 figure:nth-child(n + 5) {
    margin-top: 0;
  }

  .doc-bank-attachments.layout-2 figure:nth-child(2n),
  .doc-bank-attachments.layout-4 figure:nth-child(4n) {
    break-after: page;
    page-break-after: always;
  }
}

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

  .preview-column {
    position: static;
  }

  .a4 {
    max-width: 920px;
    margin: 0 auto;
  }
}

@media (max-width: 1100px) {
  .sidebar {
    display: none;
  }

  .topbar {
    gap: 12px;
  }

  .control-group.wide {
    min-width: 0;
  }

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

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

  .document-info-grid .payment-terms-field {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .topbar,
  .content-grid,
  .two-columns {
    display: block;
  }

  .control-group,
  .control-group.wide,
  .actions {
    margin: 0 0 12px;
    min-width: 0;
  }

  .segmented,
  .actions {
    width: 100%;
  }

  .segmented button,
  .actions button {
    flex: 1;
    min-width: 0;
  }

  .form-grid.four,
  .form-grid.provider-grid,
  .document-info-grid {
    grid-template-columns: 1fr;
  }

  .document-info-grid .inline-control-field,
  .document-info-grid .payment-terms-field,
  .provider-grid .provider-inline-field {
    grid-template-columns: 1fr;
  }

  .document-info-grid .payment-terms-field,
  .form-grid .span-three,
  .form-grid .span-two {
    grid-column: auto;
  }

  .fee-control-row,
  #settlementCommissionRow,
  .conversion-row,
  .fee-item-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .fee-control-row input[type="checkbox"],
  .fee-show {
    justify-self: start;
  }

  .fee-item-row .delete-row {
    justify-self: end;
  }

  .inline-show {
    justify-self: start;
  }
}

/* ========= Responsive (original, kept unchanged) ========= */
@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell,
  .topbar,
  .content-grid,
  .two-columns {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    padding: 14px;
  }

  .control-group,
  .control-group.wide,
  .actions {
    margin: 0 0 12px;
    min-width: 0;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
  }

  .actions {
    display: flex;
    gap: 8px;
  }

  .content-grid {
    padding: 12px;
  }

  .form-grid.four {
    grid-template-columns: 1fr;
  }

  .document-info-grid .inline-control-field,
  .document-info-grid .payment-terms-field,
  .provider-grid .provider-inline-field {
    grid-template-columns: 1fr;
  }

  .fee-control-row,
  #settlementCommissionRow,
  .conversion-row,
  .fee-item-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .fee-control-row input[type="checkbox"],
  .fee-show {
    justify-self: start;
  }

  .fee-item-row .delete-row {
    justify-self: end;
  }

  .inline-show {
    justify-self: start;
  }

  .provider-grid .provider-address-field .inline-show {
    padding-top: 0;
  }

  .form-grid .span-three {
    grid-column: auto;
  }

  .form-grid .span-two {
    grid-column: auto;
  }

  .panel {
    margin-bottom: 12px;
  }

  .preview-column {
    position: static;
    overflow: hidden;
  }

  .a4 {
    max-width: 100%;
    min-height: 0;
    padding: 18px;
    overflow: hidden;
  }

  .doc-hero,
  .parties,
  .doc-bottom {
    display: block;
  }

  .doc-title-block {
    justify-items: stretch;
    text-align: center;
    margin-top: 18px;
    width: 100%;
  }

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

  .doc-meta-grid .wide {
    grid-column: 1 / -1;
  }

  .party {
    margin-bottom: 12px;
  }

  .doc-table th,
  .doc-table td {
    padding: 5px;
    font-size: 8px;
    word-break: break-word;
  }

  .totals-table {
    margin-top: 12px;
    width: 100%;
  }
}

/* ========= Print ========= */
@page {
  size: A4;
  margin: 0;
}

@media print {
  body {
    min-width: 0;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sidebar,
  .topbar,
  .editor,
  .preview-toolbar,
  .dialog-overlay,
  .toast,
  .app-shell {
    display: none !important;
  }

  .print-pages {
    display: block !important;
  }

  .doc-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.56fr) minmax(0, 0.44fr);
    gap: 6mm;
    align-items: start;
  }

  .doc-meta-grid {
    display: grid;
    grid-template-columns: repeat(var(--meta-cols, 4), minmax(0, 1fr));
  }

  .doc-meta-grid .wide {
    grid-column: 1 / -1;
  }

  .parties,
  .doc-bottom {
    display: grid;
  }

  .parties {
    grid-template-columns: 1fr 1fr;
  }

  .doc-bottom {
    grid-template-columns: minmax(0, 1fr) 63mm;
  }

  .settlement-doc-bottom {
    grid-template-columns: minmax(0, 1fr) 96mm;
  }

  .doc-table {
    table-layout: fixed;
  }

  .doc-table th,
  .doc-table td {
    page-break-inside: avoid;
  }

  .doc-receiving-bank {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .doc-receiving-bank h3,
  .doc-bank-body {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .doc-title-block {
    width: 100%;
    min-height: 116px;
    padding: 0;
    transform: translateY(-6px);
  }

  .doc-title-block h2 {
    font-size: 40px;
    line-height: 1.38;
    transform: translateX(-6px) scaleX(0.94);
  }

  .doc-title-block .doc-title-line {
    line-height: 1.45;
  }
}

.print-pages {
  display: none;
}

.print-pages.is-measuring {
  position: absolute;
  top: 0;
  left: -100000px;
  display: block;
  visibility: hidden;
  pointer-events: none;
}

.print-page {
  width: 210mm;
  height: 297mm;
  box-sizing: border-box;
  padding: 14mm 16mm 18mm;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
  break-after: page;
  page-break-after: always;
}

.print-page:last-child {
  break-after: auto;
  page-break-after: auto;
}

.print-page-header {
  flex: 0 0 auto;
}

.print-page-header .doc-letterhead {
  margin-bottom: 10mm;
}

.print-page-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.print-page-footer {
  flex: 0 0 auto;
  margin-top: 8mm;
}

.print-page-footer .doc-page-thanks {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  display: grid;
  padding: 0 35mm;
}

.print-page-number {
  position: absolute;
  right: 16mm;
  bottom: 8mm;
  color: #334155;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.print-attachment-page {
  padding: 14mm 16mm 14mm;
}

.print-attachment-body {
  height: 100%;
}

.print-attachment-body .doc-attachment {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.print-attachment-body .doc-attachment h3 {
  margin-bottom: 5mm;
  font-size: 18px;
}

.print-attachment-body .doc-attachment h4 {
  margin-bottom: 4mm;
  font-size: 13px;
}

.print-attachment-body .doc-attachment-media {
  width: 100%;
}

.print-attachment-body .doc-attachment-pdf {
  min-height: 0;
}
