/* RentWiseAI invoices: the beige invoice icon and the viewer that shows the shared invoice paper.
   At the end: the paper itself in the new design (html.ad-on). */
:root{
  --rw-pinv-red: #b42318;
  --rw-pinv-red-2: #d92d20;
  --rw-pinv-tint: #fef3f2;
  --rw-pinv-line: #fecdca;
  --rw-pinv-ink: #1f2937;
  --rw-pinv-muted: #6b7280;
}

/* Same look as every invoice icon (.ra-invoice-file in portal.css), in the beige of RentWiseAI's paper. */
.rw-pinv-btn{
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid #e6d8bf;
  border-radius: 8px;
  background: #f7f0e3;
  color: #6b4f2a;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
}

.rw-pinv-btn svg{
  width: 17px;
  height: 17px;
}

.rw-pinv-btn:hover{
  background: #efe3cc;
  border-color: #d9c4a0;
  color: #523c1f;
}

.rw-pinv-btn[data-unpaid="1"]::after{
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--rw-pinv-red-2);
}

.rw-pinv-cell{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.rw-pinv-cell small{
  color: var(--rw-pinv-muted);
  font-size: 0.72rem;
}

.rw-pinv-none{
  color: var(--rw-pinv-muted);
}

/* The open invoice: the same paper overlay as every invoice, a red × in the paper's top-right corner,
   print to its left. Several invoices on one account: a picker under the paper. */
.rw-pinv-dialog{
  z-index: 1200 !important;
}

.rw-pinv-dialog .ra-invoice-paper-shell{
  display: flex;
  flex-direction: column;
}

.rw-pinv-x{
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 3;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #b91c1c;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.rw-pinv-print{
  position: absolute;
  top: 12px;
  right: 52px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #6b4f2a;
  cursor: pointer;
}

.rw-pinv-print:hover{
  background: #f7f0e3;
}

/* Void: left of print. Only for whoever created the invoice. */
.rw-pinv-void{
  position: absolute;
  top: 12px;
  right: 88px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b91c1c;
  cursor: pointer;
}

.rw-pinv-void:hover{
  background: #fee2e2;
}

.rw-pinv-void[hidden]{
  display: none;
}

/* The in-app confirm opens over an invoice. */
#rwAppConfirm{
  z-index: 1300 !important;
}

.rw-pinv-pick{
  order: 2;
  align-self: center;
  min-height: 34px;
  margin-top: 12px;
  padding: 0 8px;
  border: 1px solid #e6d8bf;
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

.rw-pinv-pick[hidden]{
  display: none;
}

.rw-pinv-dialog__msg{
  margin: 0;
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
}

.rw-pinv-note{
  order: 3;
  margin: 10px 0 0;
  color: #e2e8f0;
  font-size: 0.8rem;
  text-align: center;
}

.rw-pinv-note:empty{
  display: none;
}

@media print{
  body > *:not(.rw-pinv-dialog){
    display: none !important;
  }

  .rw-pinv-dialog{
    position: static !important;
    padding: 0 !important;
    background: none !important;
    overflow: visible !important;
  }

  .rw-pinv-x,
  .rw-pinv-print,
  .rw-pinv-void,
  .ra-invoice-paper-x,
  .rw-pinv-pick,
  .rw-pinv-note{
    display: none !important;
  }

  .rw-pinv-dialog .ra-invoice-paper{
    zoom: 1;
    box-shadow: none;
  }
}

/* Treasury account ledger: the invoice column. */
.ra-ledger__invoice{
  width: 64px;
  text-align: left !important;
}

/* ==========================================================================================
   The invoice and estimate paper in the new design (html.ad-on). Every invoice, estimate and
   credit note in the portal is the one paper from invoice-paper.js (classic look: the
   .ra-invoice-paper rules in portal.css). This block only changes how it looks, on screen and
   printed: white paper, navy ink, hairlines, a short gold rule over a serif title, a quiet line
   table with right-aligned figures, and a total that reads without colour (prints in black and
   white). Classic (no html.ad-on) is untouched. It lives here because the portal loads this file
   right after portal.css; invoice-paper.css is generated from portal.css and must stay a copy.
   ========================================================================================== */

html.ad-on .ra-invoice-paper{
  --paper-ink: #0f1b2d;
  --paper-ink-2: #3d4a5c;
  --paper-muted: #6b7686;
  --paper-line: #ebe7df;
  --paper-rule: #d9d3c7;
  --paper-gold: #c48a2c;
  --paper-tint: #f7f5f0;
  --paper-mark: #102d4e;
  --paper-accent: #102d4e;
  --paper-accent2: #3d4a5c;
  --paper-soft: #f7f5f0;
  --paper-head-line: #d9d3c7;
  --paper-stripe: transparent;
  --paper-sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --paper-serif: "Instrument Serif", "Iowan Old Style", Georgia, "Times New Roman", serif;
  padding: 56px 64px 40px;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  background: #fff;
  color: var(--paper-ink);
  box-shadow: 0 1px 2px rgba(15, 27, 45, 0.05), 0 28px 60px -28px rgba(15, 27, 45, 0.32);
  font-family: var(--paper-sans);
  font-size: 14px;
  line-height: 1.5;
}

/* A quiet cue for the kind of paper: only the monogram changes tone. The title says the rest. */
html.ad-on .ra-invoice-paper--estimate{ --paper-mark: #1f4d3a; }
html.ad-on .ra-invoice-paper--platform{ --paper-mark: #7a5a2e; }

/* Header: monogram and issuer on the left; gold rule, serif title and the numbers on the right. */
html.ad-on .ra-invoice-paper__head{
  gap: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--paper-line);
}

html.ad-on .ra-invoice-paper__mark{
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--paper-mark);
  color: #fff;
  font: 600 15px/1 var(--paper-sans);
  letter-spacing: 0.04em;
}

html.ad-on .ra-invoice-paper__company{
  color: var(--paper-ink);
  font: 600 18px/1.25 var(--paper-sans);
  letter-spacing: -0.01em;
}

html.ad-on .ra-invoice-paper__title h2{
  margin: 0 0 18px;
  color: var(--paper-ink);
  font: 400 44px/1 var(--paper-serif);
  letter-spacing: -0.01em;
  text-transform: none;
}

/* The gold rule over the title is a border, so it prints without "background graphics". */
html.ad-on .ra-invoice-paper__title h2::before{
  content: "";
  display: block;
  width: 28px;
  height: 0;
  margin: 0 0 14px auto;
  border-top: 2px solid var(--paper-gold);
}

/* Estimates carry no rule: just the title. */
html.ad-on .ra-invoice-paper--estimate .ra-invoice-paper__title h2::before{
  content: none;
}

html.ad-on .ra-invoice-paper__title dl{
  gap: 3px;
  font-size: 13px;
}

html.ad-on .ra-invoice-paper__title dt{
  color: var(--paper-muted);
}

html.ad-on .ra-invoice-paper__title dd{
  color: var(--paper-ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* The invoice page puts the number on the title's row (portal.css): the same serif. */
html.ad-on .ra-invoice-view .ra-invoice-paper__title [data-rw-invoice-paper-number]{
  color: var(--paper-muted);
  font: 400 44px/1 var(--paper-serif);
  letter-spacing: -0.01em;
}

html.ad-on .ra-invoice-view .ra-invoice-paper__title h2::before{
  margin-left: 0;
}

/* Parties: small uppercase labels, the name a touch heavier. */
html.ad-on .ra-invoice-paper__parties{
  gap: 32px;
  margin: 28px 0 32px;
}

html.ad-on .ra-invoice-paper h4{
  margin: 0 0 8px;
  color: var(--paper-muted);
  font: 600 11px/1.3 var(--paper-sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

html.ad-on .ra-invoice-paper__parties p,
html.ad-on .ra-invoice-paper__summary p{
  color: var(--paper-ink-2);
}

html.ad-on .ra-invoice-paper__parties p:first-of-type{
  color: var(--paper-ink);
  font-weight: 600;
}

html.ad-on .ra-invoice-paper__party-label,
html.ad-on .ra-invoice-paper [data-rw-paper-party-slot] .ra-estimate-pair > span:first-child{
  color: var(--paper-muted);
  font: 600 11px/1.3 var(--paper-sans);
  letter-spacing: 0.1em;
}

html.ad-on .ra-invoice-paper__party-line [data-rw-invoice-paper-owner]{
  color: var(--paper-ink);
  font-weight: 600;
}

/* Line items: a light header row, hairline rows, figures right-aligned in tabular numerals. */
html.ad-on .ra-invoice-paper__grid th{
  padding: 10px 12px;
  border-top: 1px solid var(--paper-line);
  border-bottom: 1px solid var(--paper-rule);
  background: var(--paper-tint);
  color: var(--paper-ink-2);
  font: 600 11px/1.3 var(--paper-sans);
  letter-spacing: 0.08em;
}

html.ad-on .ra-invoice-paper__grid td{
  padding: 14px 12px;
  border-bottom: 1px solid var(--paper-line);
}

html.ad-on .ra-invoice-paper__grid tbody tr:nth-child(even) td{
  background: transparent;
}

html.ad-on .ra-invoice-paper__grid .ra-invoice-paper__n{
  padding-right: 4px;
  color: var(--paper-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

html.ad-on .ra-invoice-paper__grid td.ra-invoice-paper__tax{
  color: var(--paper-ink);
  font-weight: 600;
}

html.ad-on .ra-invoice-paper__grid .ra-invoice-paper__amt{
  font-variant-numeric: tabular-nums;
}

html.ad-on .ra-invoice-paper__grid td.ra-invoice-paper__amt{
  color: var(--paper-ink);
  font-weight: 500;
}

html.ad-on .ra-invoice-paper__item{
  color: var(--paper-ink);
}

html.ad-on .ra-invoice-paper__desc{
  color: var(--paper-ink-2);
}

html.ad-on .ra-invoice-paper__empty{
  color: var(--paper-muted);
}

/* Totals: plain rows, then the total under a full ink rule, set large. No colour carries meaning. */
html.ad-on .ra-invoice-paper__totals{
  width: min(320px, 100%);
  margin: 20px 0 0 auto;
}

html.ad-on .ra-invoice-paper__trow{
  gap: 16px;
  padding: 6px 12px;
  color: var(--paper-ink-2);
  font-variant-numeric: tabular-nums;
}

html.ad-on .ra-invoice-paper__trow > span:last-child{
  color: var(--paper-ink);
  white-space: nowrap;
}

html.ad-on .ra-invoice-paper__trow--total{
  align-items: baseline;
  margin-top: 10px;
  padding: 14px 12px 12px;
  border-top: 2px solid var(--paper-ink);
  border-radius: 0 0 10px 10px;
  background: var(--paper-tint);
  color: var(--paper-ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

html.ad-on .ra-invoice-paper__trow--total > span:last-child{
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Typing the total on a vendor's own file: dark text now that the total is not a navy bar. */
html.ad-on #rwVendorInvoiceForm .ra-invoice-file-total #rwVendorInvoiceOwnTotal{
  border-color: var(--paper-rule);
  background: #fff;
  color: var(--paper-ink);
  -webkit-text-fill-color: var(--paper-ink);
  caret-color: var(--paper-ink);
}

html.ad-on .ra-invoice-file-total #rwVendorInvoiceOwnTotalField .ra-invoice-mark{
  color: var(--paper-muted);
}

/* Summary: a hairline card, no coloured bar. */
html.ad-on .ra-invoice-paper__summary{
  margin-top: 32px;
  padding: 18px 20px;
  border: 1px solid var(--paper-line);
  border-radius: 12px;
  background: #fcfbf8;
}

html.ad-on .ra-invoice-paper__summary p{
  line-height: 1.55;
}

/* Footer: hairline, a serif thank-you. */
html.ad-on .ra-invoice-paper__foot{
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--paper-line);
  color: var(--paper-muted);
  font-size: 12.5px;
}

html.ad-on .ra-invoice-paper__thanks{
  color: var(--paper-ink-2);
  font: italic 400 17px/1.35 var(--paper-serif);
}

html.ad-on .ra-invoice-paper__tail{
  border-top-color: var(--paper-line);
}

/* VOID / DRAFT stamps: the same stamp in the paper's type. */
html.ad-on .ra-invoice-paper__stamp,
html.ad-on .ra-invoice-paper__stamp-note{
  font-family: var(--paper-sans);
  font-weight: 700;
  letter-spacing: 0.12em;
}

/* Writing on the paper. */
html.ad-on .ra-invoice-paper__write[data-placeholder]:empty::before{
  color: #a3acb9;
}

html.ad-on .ra-invoice-paper__tax-toggle{
  border-color: var(--paper-rule);
  border-radius: 4px;
}

html.ad-on .ra-invoice-paper__tax-toggle[data-on="1"]{
  border-color: var(--paper-ink-2);
  background: #fff;
  color: var(--paper-ink);
}

html.ad-on .ra-invoice-paper__attach{
  color: var(--paper-ink-2);
}

/* Thumbnails and the viewer around the paper: the dialogs' dimmed, blurred page (design.css). */
html.ad-on .ra-invoice-paper-thumb .ra-invoice-paper{
  box-shadow: 0 1px 2px rgba(15, 27, 45, 0.06), 0 18px 40px -18px rgba(15, 27, 45, 0.3);
}

html.ad-on .ra-invoice-paper-thumb{
  border-radius: 4px;
}

html.ad-on .ra-invoice-paper-thumb:focus-visible{
  outline-color: #102d4e;
}

html.ad-on .ra-invoice-view .ra-invoice-paper{
  box-shadow: 0 1px 2px rgba(15, 27, 45, 0.05), 0 28px 60px -28px rgba(15, 27, 45, 0.32);
}

html.ad-on .ra-invoice-paper-overlay{
  background: rgba(15, 27, 45, 0.32);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* Opening a paper: the backdrop fades in and the sheet glides up into place, like a print preview.
   Showing the overlay (removing [hidden]) restarts the animation every time. */
@media screen and (prefers-reduced-motion: no-preference){
  html.ad-on .ra-invoice-paper-overlay:not([hidden]){
    animation: ad-paper-fade 0.18s ease-out;
  }

  html.ad-on .ra-invoice-paper-overlay:not([hidden]) > .ra-invoice-paper-shell{
    animation: ad-paper-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  }
}

/* Every estimate paper opens the same way. These are pinned to the window themselves (portal.css,
   translateX(-50%)) with the backdrop as their own shadow, so the shadow fades with the paper. */
@media screen and (prefers-reduced-motion: no-preference){
  html.ad-on :is(#rwAgentEstimateDetail.is-page #rwAgentEstimateBody, #rwOwnerEstimateDetail.is-page #rwOwnerEstimateBody, #rwVendorEstimateDetail.is-page #rwVendorEstimateBody, #rwVendorEstimateForm.is-page #rwVendorEstimateStory, #rwVendorEstimateForm.is-sheet #rwVendorEstimateAnswer, #rwAgentEstimateDetail.is-sheet #rwAgentEstimateToOwner){
    animation: ad-estimate-paper-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  }
}

@keyframes ad-estimate-paper-in{
  from{
    opacity: 0;
    transform: translateX(-50%) translateY(14vh) scale(0.96);
  }
}

@keyframes ad-paper-fade{
  from{ opacity: 0; }
}

@keyframes ad-paper-in{
  from{
    opacity: 0;
    transform: translateY(14vh) scale(0.96);
  }
}

html.ad-on .ra-invoice-paper-shell > .ra-invoice-paper-x,
html.ad-on .rw-pinv-x{
  border-radius: 50%;
  color: #6b7686;
  font-weight: 300;
}

html.ad-on .ra-invoice-paper-shell > .ra-invoice-paper-x:hover,
html.ad-on .rw-pinv-x:hover{
  background: #f1eee8;
  color: #0f1b2d;
}

html.ad-on .rw-pinv-print{
  color: #3d4a5c;
}

html.ad-on .rw-pinv-print:hover{
  background: #f1eee8;
  color: #0f1b2d;
}

/* Phones: the classic stacks the header; keep the margins in proportion. */
@media (max-width: 640px){
  html.ad-on .ra-invoice-paper{
    padding: 32px 20px 24px;
  }

  html.ad-on .ra-invoice-paper__title h2,
  html.ad-on .ra-invoice-view .ra-invoice-paper__title [data-rw-invoice-paper-number]{
    font-size: 36px;
  }

  html.ad-on .ra-invoice-paper__title h2::before{
    margin-left: 0;
  }

  html.ad-on .ra-invoice-paper__parties{
    gap: 20px;
  }

  /* Estimate # and Date share one row: keep them apart. */
  html.ad-on :is(.ra-invoice-paper--estimate, .ra-tx-paper .ra-invoice-paper) .ra-invoice-paper__title dl{
    column-gap: 24px;
  }
}

/* Printed and saved as PDF: no shadow, no tints (printers drop them), rows never split, and the
   totals, summary and thank-you each stay in one piece. A4 and US Letter both fit. */
@media print{
  html.ad-on .ra-invoice-paper{
    padding: 4px 0 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  /* The signed-in page is one screen tall with its overflow hidden, which cut a printed paper off
     after the first page. While the viewer prints, the page grows to the paper's full length. */
  html.ad-on:has(> body > .rw-pinv-dialog:not([hidden])),
  html.ad-on body.ra-portal--signed-in:has(> .rw-pinv-dialog:not([hidden])){
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  html.ad-on .rw-pinv-dialog .ra-invoice-paper-shell{
    width: 100%;
  }

  html.ad-on .ra-invoice-paper__mark{
    border: 1.5px solid var(--paper-ink);
    background: none;
    color: var(--paper-ink);
  }

  html.ad-on .ra-invoice-paper__head,
  html.ad-on .ra-invoice-paper__parties{
    break-inside: avoid;
  }

  html.ad-on .ra-invoice-paper__grid thead{
    display: table-header-group;
  }

  html.ad-on .ra-invoice-paper__grid th{
    border-top: 0;
    border-bottom: 1.5px solid var(--paper-ink);
    background: none;
    color: var(--paper-ink);
  }

  html.ad-on .ra-invoice-paper__grid tr{
    break-inside: avoid;
  }

  html.ad-on .ra-invoice-paper__grid td{
    border-bottom-color: #cfc9bd;
  }

  html.ad-on .ra-invoice-paper__totals,
  html.ad-on .ra-invoice-paper__summary,
  html.ad-on .ra-invoice-paper__foot{
    break-inside: avoid;
  }

  html.ad-on .ra-invoice-paper__totals{
    break-before: avoid;
  }

  html.ad-on .ra-invoice-paper__trow--total{
    border-radius: 0;
    border-bottom: 1px solid var(--paper-ink);
    background: none;
  }

  html.ad-on .ra-invoice-paper__summary{
    border-color: #cfc9bd;
    background: none;
  }

  html.ad-on .ra-invoice-paper__stamp{
    background: none;
  }
}

/* ==========================================================================================
   An invoice that came with the vendor's own file (email or upload): the Draft's "Vendor invoice:
   File" line (File opens the invoice file viewer), Received on at its right, then status and
   timeline. The file itself already shows the vendor, number, date and Bill to. Both looks.
   ========================================================================================== */

html:not(.ad-on) .ra-invoice-view .ra-invoice-paper.ra-invoice-paper--file{
  padding: 40px 48px 28px;
}

.ra-invoice-paper.ra-invoice-paper--file .ra-invoice-paper__tail{
  margin: 24px 0 0;
}

.ra-invoice-original{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  margin: 4px 0 0;
}

.ra-invoice-original > .ra-estimate-pair{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.ra-invoice-original__got{
  color: var(--paper-muted, #64748b);
  font-size: 13px;
}

@media (max-width: 640px){
  html:not(.ad-on) .ra-invoice-view .ra-invoice-paper.ra-invoice-paper--file{
    padding: 28px 18px 20px;
  }
}

/* The file invoice's window dims and blurs the page like the paper viewer does. */
html.ad-on #rwAgentInvoiceModal.is-open:has([data-rw-invoice-view]){
  background: rgba(15, 27, 45, 0.32) !important;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

@media print{
}
