/* Paper previews use the same light brand palette as the printed document.
   The application loads this sheet only for print; standalone previews load
   it for both media so browser dark mode cannot recolour a white document. */
.rx-paper-document {
  --ink: #20251e;
  --muted: #596054;
  --line: #d9d9cc;
  --soft: #f6f3ed;
  --paper: #fff;
  --white: #fff;
  --green: #294b3d;
  --orange: #b94b14;
  --rx-text: #20251e;
  --rx-muted: #596054;
  color: #20251e;
  background-color: #fff;
  color-scheme: light;
}

.rx-paper-document :is(h1, h2, h3, h4, .text-rexius-dark, [class~="text-[#032356]"]) {
  color: #20251e;
}

.rx-paper-document :is([class~="text-[#5E6F88]"], [class~="text-[#52667E]"], .label, .terms-box, .sig .name, .footer) {
  color: #596054;
}

.rx-paper-document :is(.rx-billing-parties, .payment-history-card > div:first-child, .print-soft, .print-strong, .meta, .summary > div) {
  color: #20251e;
  background: #f6f3ed !important;
  border-color: #d9d9cc;
}

.rx-paper-document :is(thead, thead tr, th) {
  color: #294b3d !important;
  background: #eeeee5 !important;
  border-color: #d9d9cc;
}

.rx-paper-document :is(.document-table-wrap, .receipt-table-wrap) tbody {
  color: #20251e;
}

.rx-paper-document .text-sky-700 { color: #294b3d; }
.rx-paper-document .text-amber-600 { color: #82511b !important; }
.rx-paper-document .text-rexius-green { color: #166534 !important; }
.rx-paper-document :is(.text-red-500, .text-red-600) { color: #b42318 !important; }

.rx-paper-document :is(.doc-title h1, .heading h1) { color: #20251e; }
.rx-paper-document :is([class~="border-[#D8E5F1]"], [class~="border-[#F7FAFD]"]) { border-color: #d9d9cc; }
.rx-paper-document .heading { border-color: #b94b14; }
.rx-paper-document .heading small { color: #294b3d; }
.rx-paper-document .status { color: #294b3d; border-color: #294b3d; }
.rx-paper-document .rx-document-letterhead { border-bottom-color: #e96b2a !important; }
.rx-paper-document.receipt .head { background: #294b3d; color: #fffdf8; }
.rx-paper-document.receipt .head h1 { color: inherit; }
.rx-paper-document.page { border-top-color: #e96b2a; }
.rx-paper-document.page > .stripe { background: #294b3d; }
.rx-paper-document .actions :is(button, a) { background: #294b3d; color: #fffdf8; }

.rx-payslip-document .accent { background: #e96b2a; }
.rx-payslip-document .hero { background: #294b3d; color: #fffdf8; }
.rx-payslip-document :is(.card, .notes) { background: #f6f3ed; border-color: #d9d9cc; }
.rx-payslip-document .summary-card:last-child { background: #f6f3ed !important; border-color: #294b3d !important; }
.rx-payslip-document .summary-card:last-child > div { color: #294b3d !important; }
.rx-payslip-document .summary-card:nth-child(2) > div:first-child { color: #82511b !important; }
.rx-authored-document .stripe { background: #e96b2a; }
.rx-authored-document .brand strong { color: #20251e; }
.rx-authored-document .brand span { color: #b94b14; }
.rx-authored-document .label { color: #294b3d; }
.rx-authored-document .meta { background: transparent !important; }
.rx-authored-document .rx-auto-stamp .stamp-status { color: #166534 !important; }

/* Use a solid accent as well as the letterhead rule: gradients are commonly
   omitted by PDF drivers and by browser background-graphics settings. */
.rx-paper-document > .bg-gradient-to-r {
  background: #294b3d !important;
}

@media screen {
  body:has(> .rx-paper-document), body:has(> .no-print + .rx-paper-document) {
    background: #f6f3ed;
  }
  .rx-paper-document + .no-print :is(button, a) {
    background: #294b3d;
    color: #fffdf8;
  }
}

.rx-paper-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .3rem 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid #d9d9cc;
  overflow-wrap: anywhere;
}

.rx-paper-heading h1 {
  margin: 0;
  color: #20251e;
  font-size: 1.5rem;
  font-weight: 700;
}

.rx-paper-reference {
  color: #596054;
  font-size: .75rem;
}

@media print {
  :root, html[data-rexius-theme] {
    color-scheme: light !important;
    --paper: #fff !important;
    --white: #fff !important;
    --ink: #20251e !important;
    --muted: #596054 !important;
    --line: #d9d9cc !important;
    --border: #d9d9cc !important;
    --soft: #f6f3ed !important;
    --green: #294b3d !important;
    --orange: #b94b14 !important;
    --accent: #294b3d !important;
    --accent-soft: #f6f3ed !important;
    --rx-text: #20251e !important;
    --rx-muted: #596054 !important;
    --rx-card: #fff !important;
    --rx-panel: #fff !important;
    --rx-border: #d9d9cc !important;
    --rx-line: #d9d9cc !important;
    --rx-soft: #f6f3ed !important;
    --rx-glass: #fff !important;
    --rx-glass-muted: #f6f3ed !important;
    --rx-blue: #294b3d !important;
  }

  *, *::before, *::after {
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }

  html, body {
    min-height: 0 !important;
    background: #fff !important;
    color: #20251e !important;
    overflow: visible !important;
  }

  :where(.no-print, #sidebar-container, #rexius-topbar, #mobile-sidebar-toggle, #mobile-overlay,
    #rxCommandSearch, .rx-skip-link, .rx-node-footer, .rx-shell-actions, .rx-shell-panel,
    .rx-filterbar, .rx-table-footer, .rx-columns-menu, .rx-modal-normalized,
    [id$="Modal"], [id$="-modal"], [data-workspace-modal], .rx-toast-region) {
    display: none !important;
  }

  .rx-print-only {
    display: block !important;
  }

  /* The letterhead already provides the printed accent rule. Keep the screen
     card's absolute top stripe away from the first line of the letterhead. */
  .rx-paper-document > .bg-gradient-to-r {
    display: none !important;
  }

  .rx-paper-heading.rx-print-only {
    display: flex !important;
  }

  body:has(#sidebar-container) {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  :where(body:has(#sidebar-container)) > :is(main, .shell, .rx-node-main) {
    width: 100% !important;
    max-width: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #20251e;
  }

  :where(body:has(#sidebar-container)) :where(main, .shell)
    :is(.text-white, .text-slate-100, .text-slate-200, .text-slate-300):not(:where(.paper *, .report-page *, .invoice-sheet *)) {
    color: #20251e !important;
  }

  :where(.rx-table-scroll, .rx-datatable, .overflow-x-auto, .overflow-y-auto) {
    max-height: none !important;
    overflow: visible !important;
  }

  :where(.rx-table-scroll, .overflow-x-auto) > table {
    min-width: 0 !important;
    max-width: 100%;
  }

  :where(main, .shell, .rx-paper-document, #print-area) table {
    break-inside: auto !important;
    max-width: 100%;
  }

  :where(main, .shell, .rx-paper-document, #print-area) thead {
    display: table-header-group;
  }

  :where(main, .shell, .rx-paper-document, #print-area) tr {
    break-inside: avoid;
  }

  :where(main, .shell, .rx-paper-document, #print-area) :is(th, td) {
    overflow-wrap: anywhere;
  }

  .rx-data-table th {
    position: static !important;
  }

  .rx-document-letterhead, .rx-paper-heading {
    break-inside: avoid !important;
    break-after: avoid-page;
  }

  :is(.rx-paper-document, #print-area, .paper, .annual-document, .rx-payroll-payslip) {
    color: #20251e;
    color-scheme: light;
  }

  :is(#print-area, .paper, .annual-document, .rx-paper-document) :is(thead, thead tr, th) {
    background: #eeeee5 !important;
    color: #294b3d !important;
    -webkit-text-fill-color: #294b3d !important;
  }

  :is(#print-area, .paper, .annual-document, .rx-paper-document) :is(.text-slate-400, .text-slate-500, .text-gray-400, .text-gray-500) {
    color: #596054 !important;
    -webkit-text-fill-color: currentColor !important;
  }

  .rx-document-letterhead { border-bottom-color: #e96b2a !important; }

  .rx-document-letterhead span[style*="color:#0161AF"] { color: #e96b2a !important; }
  .rx-document-letterhead :is(h1, h2, h3) { color: #20251e !important; }
  .rx-document-letterhead :is([style*="color:#7C8CA2"], [style*="color:#B8C8DA"]) { color: #596054 !important; }

  .rx-paper-document, #print-area {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .rx-paper-heading {
    margin-bottom: 3mm;
    padding-bottom: 2mm;
  }

  .rx-billing-parties {
    break-inside: avoid;
    gap: 5mm;
    margin-bottom: 3mm !important;
    padding: 2.5mm !important;
  }

  :is(.rx-paper-document, .rx-receipt-closeout) > :is(.summary-section, .payment-history-card, .document-table-wrap, .receipt-table-wrap) {
    margin-block: 3mm !important;
  }

  .rx-paper-document :is(.document-table-wrap, .receipt-table-wrap, .payment-history-card) :is(th, td) {
    padding-block: 1.3mm;
  }

  .rx-paper-document :is(.document-table-wrap, .receipt-table-wrap) td img {
    width: 7mm;
    height: 7mm;
  }

  .rx-paper-document .payment-history-card > div:first-child {
    padding-block: 1.6mm;
  }

  .rx-billing-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .rx-paper-document .rx-receipt-closeout {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }
}
