/* Company profiles and payer selection share the compact CRM card layout. */
.company-lookup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px 12px;
  margin-bottom: 12px;
}
.company-lookup .field { min-width: 0; margin: 0; }
.company-lookup .input { width: 100%; min-width: 0; }
.company-lookup-status { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }
.company-fields.payer-identity { margin-top: 0; padding-top: 0; border-top: 0; }
@media (max-width: 540px) {
  .company-lookup { grid-template-columns: minmax(0, 1fr); }
  .company-lookup > button { justify-self: start; max-width: 100%; }
}
.company-profile-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-width: 0;
  margin: 18px 0 10px;
}
.company-profile-heading h3,
.company-profile-heading h4 { margin: 0; font-size: 12px; }
.company-profile-heading > * { min-width: 0; max-width: 100%; }
.company-profile-heading small { color: var(--muted, #69737d); font-size: 11px; }
.company-requisites {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  min-width: 0;
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
}
.company-requisites > div { min-width: 0; }
.company-requisites dt { margin: 0 0 3px; color: var(--muted, #69737d); font-size: 11px; }
.company-requisites dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
section.company-requisites { display: block; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line, #dfe3e5); }
section.company-requisites > h3 { margin: 0 0 12px; font-size: 12px; }
section.company-requisites > h4 { margin: 16px 0 8px; font-size: 12px; }
section.company-requisites > dl,
.company-bank-row > dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; min-width: 0; margin: 0; }
section.company-requisites > dl > div,
.company-bank-row > dl > div { min-width: 0; }
.company-requisites .is-wide,
.company-fields .is-wide,
.company-bank-row .is-wide { grid-column: 1 / -1; }
.company-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 14px 0;
  padding-top: 14px;
  border-top: 1px solid var(--line, #dfe3e5);
}
.company-fields > *,
.company-bank-row > * { min-width: 0; }
.company-fields .field > span,
.company-bank-row .field > span,
.invoice-form .field > span { color: var(--muted, #69737d); font-size: 11px; }
.company-fields input,
.company-fields select,
.company-fields textarea,
.company-bank-row input,
.company-bank-row select,
.company-bank-row textarea,
.payer-card input,
.payer-card select,
.invoice-form input,
.invoice-form select,
.invoice-form textarea { min-width: 0; max-width: 100%; }
.company-fields textarea,
.invoice-form textarea { min-height: 62px; resize: vertical; }
.company-bank-list { display: grid; gap: 10px; min-width: 0; margin: 10px 0 14px; }
.company-bank-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line, #dfe3e5);
  border-left: 3px solid #b6cd98;
  border-radius: 3px;
  background: #fbfcf9;
}
.company-bank-row .company-profile-heading { grid-column: 1 / -1; margin: 0; }
.company-bank-row .company-requisites { grid-column: 1 / -1; }
.company-bank-row > strong,
.company-bank-row > dl { grid-column: 1 / -1; }
.company-bank-row > .company-fields { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
.company-bank-row + .company-bank-row { margin-top: 10px; }
.company-bank-list .company-bank-row + .company-bank-row { margin-top: 0; }
.company-bank-row .button-row { grid-column: 1 / -1; margin: 0; }
.company-bank-row .link-button { justify-self: start; font-size: 11px; }
.company-bank-row .client-primary-choice { align-self: center; white-space: normal; }
.payer-card { min-width: 0; }
.payer-card .card-heading { flex-wrap: wrap; gap: 6px 10px; }
.payer-card .card-heading h2,
.payer-card .card-heading h3 { margin: 0; font-size: 12px; }
.payer-card .card-body { display: grid; gap: 10px; }
.payer-card .field { min-width: 0; }
.payer-card .field > span { color: var(--muted, #69737d); font-size: 11px; }
.payer-card select { text-overflow: ellipsis; }
.payer-details {
  min-width: 0;
  padding: 9px 10px;
  border-left: 3px solid #b6cd98;
  background: var(--accent-soft, #f0f6e7);
  font-size: 11px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.payer-details strong { font-size: 12px; }
.payer-details p { margin: 4px 0 0; }
.payer-details > small { display: block; margin-top: 4px; color: var(--muted, #69737d); }
.payer-details .link-button { padding: 0; font-size: 12px; text-align: left; white-space: normal; }
.payer-details .company-requisites { gap: 8px; margin-top: 8px; font-size: 11px; }
.invoice-list { display: grid; gap: 9px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.card.invoice-list { display: block; }
.card.invoice-list > .card-body { display: grid; gap: 9px; }
.invoice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line, #dfe3e5);
  border-radius: 3px;
  background: var(--surface, #fff);
}
.invoice-row > * { min-width: 0; max-width: 100%; }
.invoice-row > div:first-child { flex: 1 1 180px; }
.invoice-row strong { color: var(--ink, #424b54); font-size: 12px; }
.invoice-row small,
.invoice-row p { display: block; margin: 4px 0 0; color: var(--muted, #69737d); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.invoice-row .button-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 0; }
.invoice-row .button { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.invoice-row .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
#invoice-dialog,
#invoice-preview-dialog {
  width: min(720px, calc(100vw - 32px));
  max-width: 720px;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line, #dfe3e5);
  border-radius: 4px;
  background: var(--surface, #fff);
  color: var(--ink, #424b54);
  box-shadow: 0 18px 50px rgb(24 44 63 / 20%);
}
#invoice-preview-dialog { width: min(920px, calc(100vw - 24px)); max-width: 920px; background: var(--page, #f2f3f5); }
#invoice-dialog > .card-heading,
#invoice-preview-dialog > .card-heading { flex-wrap: wrap; gap: 10px; padding: 16px 20px; background: var(--surface, #fff); }
#invoice-dialog .card-heading > div,
#invoice-preview-dialog .card-heading > div { min-width: 0; }
#invoice-dialog .card-heading .button-row,
#invoice-preview-dialog .card-heading .button-row { display: flex; flex-wrap: wrap; gap: 8px; }
#invoice-dialog > .card-body.invoice-list { padding: 18px 20px 20px; }
.invoice-form { display: grid; gap: 13px; min-width: 0; padding: 18px 20px 20px; }
.invoice-form .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.invoice-form .button-row { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.invoice-form .help { margin: 0; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.invoice-document {
  width: auto;
  max-width: 794px;
  min-width: 0;
  margin: 20px auto;
  padding: 30px 32px;
  background: #fff;
  color: #424b54;
  box-shadow: 0 2px 12px rgb(28 39 46 / 7%);
  font-family: "Open Sans", Arial, sans-serif;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.invoice-document-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 15px; border-bottom: 4px solid #71be00; }
.invoice-document-header > div { min-width: 0; }
.invoice-document-header img { flex: 0 0 auto; width: 72px; max-width: 25%; height: auto; object-fit: contain; }
.invoice-document-header h1,
.invoice-document-header h2 { margin: 0; color: #353e48; font-size: 21px; }
.invoice-document-header p { margin: 4px 0 0; color: #69737d; font-size: 11px; }
.invoice-document-parties { display: grid; gap: 12px; min-width: 0; margin: 20px 0; }
.invoice-document-parties > * { min-width: 0; }
.invoice-document-parties p { margin: 3px 0; white-space: pre-wrap; }
.invoice-document-parties strong { color: #353e48; }
.invoice-document-parties .company-requisites { margin-top: 8px; gap: 7px 15px; font-size: 11px; }
.invoice-document-table { width: 100%; min-width: 0; border-collapse: collapse; table-layout: fixed; }
.invoice-document-table th { padding: 8px 6px; background: #353e48; color: #fff; font-size: 10px; font-weight: 600; text-align: left; }
.invoice-document-table td { padding: 9px 6px; border-bottom: 1px solid #e2e6e8; color: #424b54; font-size: 11px; vertical-align: top; }
.invoice-document-table th,
.invoice-document-table td { overflow-wrap: anywhere; }
.invoice-document-table th:first-child,
.invoice-document-table td:first-child { width: 6%; }
.invoice-document-table th:nth-child(2),
.invoice-document-table td:nth-child(2) { width: 42%; }
.invoice-document-table th:nth-child(n + 3),
.invoice-document-table td:nth-child(n + 3) { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-document-table tbody tr:nth-child(even) { background: #f6f8f3; }
.invoice-total { display: flex; align-items: baseline; justify-content: flex-end; flex-wrap: wrap; gap: 6px 22px; margin: 16px 0; padding: 12px 14px; border-left: 3px solid #71be00; background: #f0f6e7; }
.invoice-total strong { color: #353e48; font-size: 21px; font-variant-numeric: tabular-nums; }
.invoice-document > small,
.invoice-document > .help { display: block; margin-top: 16px; color: #69737d; font-size: 10px; line-height: 1.5; }

@media (max-width: 620px) {
  .company-fields,
  .company-bank-row,
  .company-requisites,
  section.company-requisites > dl,
  .company-bank-row > dl,
  .invoice-form .field-grid { grid-template-columns: minmax(0, 1fr); }
  #invoice-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  #invoice-dialog > .card-heading,
  #invoice-preview-dialog > .card-heading,
  .invoice-form { padding: 14px; }
  .invoice-document { margin: 10px; padding: 20px 14px; }
  .invoice-document-header { gap: 10px; }
  .invoice-document-header h1,
  .invoice-document-header h2 { font-size: 18px; }
  .invoice-document-table th,
  .invoice-document-table td { padding: 7px 3px; font-size: 9px; }
  .invoice-total strong { font-size: 19px; }
}

@media print {
  .invoice-document { max-width: none; margin: 0; padding: 0; box-shadow: none; font-size: 10pt; }
  .invoice-document-header,
  .invoice-document-parties,
  .invoice-document-table tr,
  .invoice-total { break-inside: avoid; }
  .invoice-document-table thead { display: table-header-group; }
  .invoice-document { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
#payer-create-dialog {
  width: min(820px, calc(100vw - 24px));
  max-width: 820px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--line, #dfe3e5);
  border-radius: 5px;
}
#payer-create-dialog > .card-heading { padding: 16px 20px; }
#payer-create-dialog > .card-body { min-width: 0; padding: 18px 20px; }
