/* ==========================================================================
   Public document pages (customers theme): invoice, estimate, proposal, contract, subscription.
   Topo design: header card (logo or company name + status + actions), document card, ink table header.
   Loaded by themes/perfex/functions.php; everything is scoped by the body classes set by the controllers.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@500&display=swap');

body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml {
  --tpd-accent: #0B5ED7; --tpd-accent-h: #094DB1; --tpd-ink: #1F2350; --tpd-soft: #E4EEFD;
  --tpd-line: #E3E6EA; --tpd-line2: #EEF0F2; --tpd-bg: #F7F8F9; --tpd-text: #2B3038; --tpd-muted: #646B76; --tpd-title: #111418;
  background: var(--tpd-bg) !important; color: var(--tpd-text); font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) :is(h1, h2, h3, h4, h5) { font-family: 'Space Grotesk', Inter, sans-serif; color: var(--tpd-title); }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) #content > .container { max-width: 1120px; }

/* ---------- header card: brand | status + actions ---------- */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  margin: 24px 0 0 !important; padding: 16px 20px; background: #fff; border: 1px solid var(--tpd-line); border-radius: 16px;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .row { margin: 0; flex: 0 1 auto; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .row > [class*="col-"] { width: auto; float: none; padding: 0; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .row > .clearfix,
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .row > [class*="col-"]:empty { display: none; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper .mbot30 { margin: 0 !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top { flex: 1 1 auto; min-width: 0; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top > .container { width: auto; max-width: none; padding: 0; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top .row { margin: 0; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top .col-md-12 {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 0;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top .col-md-12 > .pull-left { margin-right: auto; float: none !important; display: flex; align-items: center; gap: 10px; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top .col-md-12 > .pull-right,
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top .col-md-12 > form { float: none !important; margin: 0 !important; order: 2; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top .col-md-12 > :is(.clearfix, .visible-xs) { display: none !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top h3,
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top h4 { margin: 0 !important; font-size: 15px; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top h4 small { display: block; margin-top: 2px; font: 400 13px Inter, sans-serif; color: var(--tpd-muted); }

/* brand: logo, or the company name when there is no logo */
.tpd-brand { display: inline-flex; align-items: center; }
.tpd-brand-logo img { max-height: 44px; width: auto; }
a.tpd-brand-name {
  font: 700 22px/1.1 'Space Grotesk', Inter, sans-serif; letter-spacing: .02em; text-transform: uppercase; color: var(--tpd-ink, #1F2350) !important; text-decoration: none !important;
}
a.tpd-brand-name::before { content: ''; width: 10px; height: 10px; margin-right: 10px; border-radius: 3px; background: var(--tpd-accent, #0B5ED7); }

/* sticky header (after scrolling) */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-sticky-header {
  background: rgba(255, 255, 255, .96) !important; border-bottom: 1px solid var(--tpd-line); box-shadow: 0 6px 20px rgba(31, 35, 80, .06); backdrop-filter: blur(6px); padding: 10px 0 !important; z-index: 100;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-sticky-header > .container { max-width: 1120px; padding: 0 20px !important; }

/* status pill */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) :is(.invoice-html-status, .estimate-html-status) .label,
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .content-view-status {
  display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px !important; font: 600 12px/1 Inter, sans-serif; text-transform: none; letter-spacing: 0;
}

/* buttons */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px; margin-top: 0 !important;
  border-radius: 10px !important; font: 600 13.5px Inter, sans-serif; text-transform: none; letter-spacing: 0; box-shadow: none !important;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .btn-default { background: #fff; border: 1px solid #DDE1E6; color: var(--tpd-title); }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .btn-default:hover { border-color: var(--tpd-accent); background: var(--tpd-soft); color: var(--tpd-ink); }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) :is(.btn-success, .btn-info, .btn-primary) { background: var(--tpd-accent) !important; border: 1px solid var(--tpd-accent) !important; color: #fff !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) :is(.btn-success, .btn-info, .btn-primary):hover { background: var(--tpd-accent-h) !important; border-color: var(--tpd-accent-h) !important; }

/* overdue banner */
:is(body.viewinvoice) .danger-bg { margin-top: 24px; padding: 10px 14px; border-radius: 12px; background: #FDECEC !important; border: 1px solid #F6C9C9; color: #B42318 !important; }
:is(body.viewinvoice) .danger-bg h5 { margin: 0; color: inherit; font: 600 13.5px Inter, sans-serif; }

/* ---------- document card ---------- */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .panel_s {
  margin-top: 16px !important; background: #fff; border: 1px solid var(--tpd-line) !important; border-radius: 16px !important; box-shadow: none !important;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .panel_s > .panel-body { padding: 32px 28px; border: 0 !important; border-radius: 16px !important; background: transparent; }
:is(body.viewinvoice, body.viewestimate) .panel_s > .panel-body > .col-md-10 { float: none; width: 100%; margin: 0; padding: 0; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) :is(.invoice-html-number, .estimate-html-number) { margin: 0 0 10px; font: 700 26px/1.15 'Space Grotesk', Inter, sans-serif !important; color: var(--tpd-ink) !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) address {
  margin-bottom: 14px; line-height: 1.65; font-style: normal; color: var(--tpd-text);
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .transaction-html-info-col-right > span.bold,
:is(body.viewinvoice, body.viewestimate) :is(.invoice-html-bill-to, .invoice-html-ship-to, .estimate-html-bill-to, .estimate-html-ship-to) {
  display: block; margin-bottom: 4px; font: 500 11px/1.2 'IBM Plex Mono', monospace !important; letter-spacing: .1em; text-transform: uppercase; color: var(--tpd-muted);
}
:is(body.viewinvoice, body.viewestimate) .transaction-html-info-col-right p.no-mbot { color: var(--tpd-muted); }
:is(body.viewinvoice, body.viewestimate) .transaction-html-info-col-right p.no-mbot span.bold { color: var(--tpd-title); font-weight: 600; }

/* items table: ink header band, light rows */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items,
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.table.items-preview {
  border-collapse: separate !important; border-spacing: 0; border: 1px solid var(--tpd-line); border-radius: 12px !important; overflow: hidden; margin: 24px 0 8px;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items thead th {
  background: var(--tpd-ink) !important; color: #fff !important; border: 0 !important; border-radius: 0 !important; padding: 13px 14px !important;
  font: 500 11px/1.2 'IBM Plex Mono', monospace !important; letter-spacing: .1em; text-transform: uppercase; vertical-align: middle;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items tbody td {
  padding: 14px !important; border: 0 !important; border-top: 1px solid var(--tpd-line2) !important; border-radius: 0 !important; vertical-align: top; color: var(--tpd-text);
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items tbody tr:first-child td { border-top: 0 !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items tbody td .description_item,
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items tbody td strong { color: var(--tpd-title); font-weight: 600; }

/* totals */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right { margin-top: 8px; border-collapse: separate; border-spacing: 0; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right td { padding: 11px 14px !important; border: 0 !important; border-top: 1px solid var(--tpd-line2) !important; border-radius: 0 !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right tr:first-child td { border-top: 0 !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right tr.total td,
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right tr:last-child td {
  background: var(--tpd-ink); color: #fff !important; font: 700 15px 'Space Grotesk', Inter, sans-serif; border-top: 0 !important;
}
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right tr:last-child td:first-child { border-radius: 10px 0 0 10px !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right tr:last-child td:last-child { border-radius: 0 10px 10px 0 !important; color: #9EC5FE !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.subscriptionhtml) table.table.text-right tr:last-child td * { color: inherit !important; }

/* amount in words, notes, terms, payments */
:is(body.viewinvoice, body.viewestimate, body.proposal-view) [class*="total-to-words"] p {
  display: inline-block; margin: 10px 0 0; padding: 8px 16px; border-radius: 999px; background: var(--tpd-soft); color: #0A4698 !important; font-weight: 600;
}
:is(body.viewinvoice, body.viewestimate) :is(.invoice-html-note, .invoice-html-terms-and-conditions, .estimate-html-note, .estimate-html-terms-and-conditions, .invoice-html-payments) {
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--tpd-line2); line-height: 1.65;
}
:is(body.viewinvoice, body.viewestimate) :is(.invoice-html-note, .invoice-html-terms-and-conditions, .estimate-html-note, .estimate-html-terms-and-conditions, .invoice-html-payments) > :is(p.bold, h4, b:first-child) {
  display: block; margin: 0 0 8px; font: 500 11px/1.2 'IBM Plex Mono', monospace !important; letter-spacing: .1em; text-transform: uppercase; color: var(--tpd-muted);
}
:is(body.viewinvoice) .invoice-payments-table { border: 1px solid var(--tpd-line); border-radius: 12px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
:is(body.viewinvoice) .invoice-payments-table thead th { background: var(--tpd-bg); border: 0 !important; border-radius: 0 !important; font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--tpd-muted); }
:is(body.viewinvoice) .invoice-payments-table td { border: 0 !important; border-top: 1px solid var(--tpd-line2) !important; border-radius: 0 !important; }

/* online payment box */
:is(body.viewinvoice) .online-payment-radio label { font-weight: 500; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .form-control { height: 40px; border: 1px solid #DDE1E6; border-radius: 10px; box-shadow: none; }

/* proposal / contract: side blocks and tabs */
:is(body.proposal-view, body.contract-view) .nav-tabs { border-bottom: 1px solid var(--tpd-line); }
:is(body.proposal-view, body.contract-view) .nav-tabs > li > a { border: 0 !important; border-radius: 0 !important; color: var(--tpd-muted); font-weight: 600; }
:is(body.proposal-view, body.contract-view) .nav-tabs > li.active > a { color: var(--tpd-ink) !important; box-shadow: inset 0 -2px 0 var(--tpd-accent); background: transparent !important; }

@media (max-width: 767px) {
  :is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .top .col-md-12 { justify-content: flex-start; }
  :is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .panel_s > .panel-body { padding: 20px 16px; }
  :is(body.viewinvoice, body.viewestimate) .transaction-html-info-col-right { text-align: left !important; }
}

/* brand flush left (theme spacing of the logo boxes); square section dividers */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper [class*="-html-logo"] { margin: 0 !important; padding: 0 !important; text-align: left !important; width: auto !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .preview-top-wrapper > .row > [class*="col-"] { margin-left: 0 !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .panel-body [class*="col-md-12"], 
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .panel-body hr { border-radius: 0 !important; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) .panel-body hr { border-top-color: var(--tpd-line2); }

/* items: quantities / prices / amounts never wrap (proposal columns are narrow) */
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items :is(th, td):not(:nth-child(2)) { white-space: nowrap; }
:is(body.viewinvoice, body.viewestimate, body.proposal-view, body.contract-view, body.subscriptionhtml) table.items :is(th, td):nth-child(2) { width: 100%; }
