/* The invoice document. Shared by the admin preview and the client's page. */
.invoice {
  --i-ink: #1f2a5c; --i-soft: #5a6488; --i-rule: #c9d0dc; --i-stamp: #b3261e; --i-paper: #fff;
  background: var(--i-paper); color: var(--i-ink);
  font: 400 15px/1.5 "Public Sans", system-ui, sans-serif; font-variant-numeric: tabular-nums;
  max-width: 800px; margin: 0 auto; padding: 3rem 3.25rem; position: relative;
}
.invoice h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1; }
.invoice h2 { font-size: .95rem; font-weight: 600; margin: 0 0 .6rem; color: var(--i-soft); }
.invoice h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .4rem; }
.invoice .pre { white-space: pre-line; }
.invoice .soft { color: var(--i-soft); font-size: .9rem; margin: .4rem 0 0; }
.invoice .num { text-align: right; }

.inv-head { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding-bottom: 1.25rem; border-bottom: 3px solid var(--i-ink); }
.inv-head .from { flex: 1; }
.inv-head .from strong { display: block; font-size: 1.15rem; margin-bottom: .25rem; }
.inv-head .title { flex: 1; text-align: right; position: relative; }
.inv-head .number { font-size: 1.15rem; font-weight: 600; margin-top: .3rem; }

/* The rubber stamp: the one loud element, only on paid or void invoices */
.stamp {
  position: absolute; right: -1rem; top: 3.2rem; transform: rotate(-12deg);
  font-size: 2rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--i-stamp); border: 4px solid var(--i-stamp); border-radius: 6px; padding: .1rem .7rem;
  opacity: .85; mix-blend-mode: multiply;
}

.inv-meta { display: flex; justify-content: space-between; gap: 2rem; padding: 1.5rem 0; }
.inv-meta .lbl { color: var(--i-soft); font-size: .85rem; margin-bottom: .25rem; }
.inv-meta .billto strong { font-size: 1.05rem; }
.facts { margin: 0; min-width: 260px; }
.facts div { display: flex; justify-content: space-between; gap: 1.5rem; padding: .3rem 0; border-bottom: 1px solid var(--i-rule); }
.facts dt { color: var(--i-soft); }
.facts dd { margin: 0; text-align: right; }
.facts .big { border-bottom: 0; padding-top: .6rem; }
.facts .big dd { font-size: 1.35rem; font-weight: 700; }
.facts .due-over { color: var(--i-stamp); font-weight: 600; }

.inv-items { width: 100%; border-collapse: collapse; margin: .5rem 0 2rem; }
.inv-items th { text-align: left; font-weight: 500; font-size: .85rem; color: var(--i-soft); padding: .5rem .5rem; border-bottom: 2px solid var(--i-ink); }
.inv-items td { padding: .7rem .5rem; border-bottom: 1px solid var(--i-rule); vertical-align: top; }
.inv-items th.num, .inv-items td.num { text-align: right; white-space: nowrap; }
.inv-items tfoot td { border-bottom: 0; padding: .4rem .5rem; color: var(--i-soft); }
.inv-items tfoot td:first-child { text-align: right; }
.inv-items tfoot .grand td { color: var(--i-ink); font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--i-ink); padding-top: .7rem; }

.kv { margin: 0; }
.kv div { display: flex; gap: .75rem; padding: .15rem 0; }
.kv dt { color: var(--i-soft); min-width: 7.5em; }
.kv dd { margin: 0; }
.terms, .notes { padding: 1rem 0 0; border-top: 1px solid var(--i-rule); margin-top: .5rem; }
.terms p, .notes p { margin: 0; }

/* Client-facing page */
body.public { margin: 0; background: #eef1f4; font-family: "Public Sans", system-ui, sans-serif; }
.public-bar { max-width: 800px; margin: 0 auto; padding: 1rem 1.25rem; display: flex; justify-content: space-between; align-items: center; color: #5a6488; font-size: .9rem; }
.public-bar button { font: inherit; background: none; border: 1px solid #5a6488; color: #1f2a5c; padding: .4rem .8rem; border-radius: 4px; cursor: pointer; }
body.public .invoice { margin-bottom: 3rem; box-shadow: 0 1px 2px rgba(31,42,92,.08), 0 8px 24px rgba(31,42,92,.08); }

@media (max-width: 640px) {
  .invoice { padding: 1.75rem 1.25rem; }
  .inv-meta { flex-direction: column; gap: 1.25rem; }
  .inv-head { flex-wrap: wrap; }
  .inv-head .logo { order: -1; width: 100%; height: 64px; object-fit: contain; object-position: left; }
  .inv-head .from, .inv-head .title { flex: 1 1 45%; }
  .stamp { right: 0; top: 0; }
  .facts { min-width: 0; }
  .inv-items th:nth-child(2), .inv-items td:nth-child(2), .inv-items th:nth-child(3), .inv-items td:nth-child(3) { display: none; }
}
@media print {
  body.public { background: #fff; }
  .public-bar { display: none; }
  body.public .invoice { box-shadow: none; max-width: none; padding: 0; }
  .pay-btn { border: 1px solid #000; color: #000; background: none; box-shadow: none; }
  .pay-opt h3 { background: none; color: #000; border-bottom: 2px solid #000; padding-left: 0; }
  .pay-opt { break-inside: avoid; }
  @page { margin: 18mm; }
}
.inv-items .details { color: var(--i-soft); font-size: .9rem; margin-top: .15rem; }
.inv-items .calc { color: var(--i-soft); font-size: .8rem; margin-top: .15rem; white-space: nowrap; }
.notice { max-width: 800px; margin: 0 auto 1rem; padding: 1rem 1.25rem; background: #fff; border-left: 4px solid #1f2a5c; color: #1f2a5c; font-size: .95rem; line-height: 1.5; }
.notice strong { display: block; margin-bottom: .2rem; }
.notice-ok { border-left-color: #1f7a4d; }
.notice-err { border-left-color: #b3261e; }
@media print { .notice { display: none; } }

/* How to pay: one card per method, header bar in ink, body on paper */
.pay { padding: 1.75rem 0 .5rem; border-top: 1px solid var(--i-rule); }
.pay-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }
.pay-opt { border: 1px solid var(--i-rule); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; }
.pay-opt h3 { margin: 0; padding: .6rem .9rem; background: var(--i-ink); color: #fff; font-size: .85rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.pay-body { padding: 1rem .9rem 1.1rem; flex: 1; }
.pay-body > :last-child { margin-bottom: 0; }
.kv { margin: 0; }
.kv div { display: flex; gap: .75rem; padding: .15rem 0; }
.kv dt { color: var(--i-soft); min-width: 7.5em; }
.kv dd { margin: 0; }

/* Online payment card: centered, with the one button that should pull the eye */
.pay-online .pay-body { text-align: center; }
.pay-online form { margin: .25rem 0 .5rem; }
.pay-btn {
  --btn: #1a9b63; --btn-dark: #157f51;
  display: inline-block; width: 100%; max-width: 260px; font: inherit; font-size: 1.05rem; font-weight: 700;
  color: #fff; background: linear-gradient(180deg, var(--btn), var(--btn-dark));
  border: 0; border-radius: 8px; padding: .85rem 1.4rem; cursor: pointer;
  box-shadow: 0 2px 0 #0f6640, 0 6px 16px rgba(26,155,99,.35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.pay-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 0 #0f6640, 0 10px 22px rgba(26,155,99,.4); }
.pay-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #0f6640, 0 4px 10px rgba(26,155,99,.3); }
.pay-btn:focus-visible { outline: 3px solid #1a9b63; outline-offset: 3px; }
.secure { margin: 0 0 .9rem; font-size: .85rem; font-weight: 500; color: var(--i-soft); }
.secure::before { content: "\1F512\FE0E  "; font-size: .8em; }
.pay-text { text-align: left; margin-top: .5rem; }
.pay-text .soft { margin: 0 0 .9rem; }
.pay-text .fee p { margin: 0 0 .7rem; font-size: .72rem; line-height: 1.45; color: var(--i-soft); }
.pay-text .fee p:last-child { margin-bottom: 0; }
@media (max-width: 640px) { .pay-grid { grid-template-columns: 1fr; } }
.ref { text-align: center; margin-top: 1rem; padding-top: .8rem; border-top: 1px dashed var(--i-rule); }
.ref .soft { text-align: left; margin: 0 0 .8rem; }
.ref-lbl { margin: 0; font-size: .85rem; color: var(--i-soft); }
.ref-num { margin: .1rem 0 0; font-size: 1.08rem; font-weight: 700; letter-spacing: .02em; }
.inv-head .logo { display: block; height: 84px; width: auto; max-width: 160px; flex: none; }

.bar-actions { display: flex; gap: .5rem; }
.bar-actions a { font: inherit; text-decoration: none; background: #1f2a5c; color: #fff; padding: .4rem .8rem; border-radius: 4px; border: 1px solid #1f2a5c; }
body.for-pdf .public-bar, body.for-pdf .notice { display: none; }
body.for-pdf { background: #fff; }
body.for-pdf .invoice { box-shadow: none; margin: 0; max-width: none; padding: 0; }

/* ---- Status tracker + amount box ---- */
.track { display: flex; justify-content: space-between; align-items: center; gap: 2rem; margin: 1.5rem 0 .5rem; padding: 1rem 1.25rem; background: #f4f6f9; border: 1px solid var(--i-rule); border-radius: 8px; }
.steps { display: flex; list-style: none; margin: 0; padding: 0; flex: 1; counter-reset: s; }
.steps li { position: relative; flex: 1; display: flex; align-items: center; gap: .6rem; font-size: .85rem; font-weight: 600; color: var(--i-soft); }
.steps li span:last-child { display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.steps li small { font-weight: 400; font-size: .75rem; color: var(--i-soft); }
.steps li::after { content: ""; flex: 1; min-width: 14px; height: 2px; background: var(--i-rule); margin: 0 .75rem; }
.steps li:last-child::after { display: none; }
.steps .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--i-rule); background: #fff; display: grid; place-items: center; flex: none; color: #fff; }
.steps .dot svg { width: 13px; height: 13px; }
.steps li.done { color: var(--i-ink); }
.steps li.done .dot { background: var(--i-ink); border-color: var(--i-ink); }
.steps li.done::after { background: var(--i-ink); }
.steps li.now { color: var(--i-ink); }
.steps li.now .dot { border-color: var(--i-ink); box-shadow: 0 0 0 4px rgba(31,42,92,.12); }
.steps li.late { color: var(--i-stamp); }
.steps li.late .dot { border-color: var(--i-stamp); background: var(--i-stamp); }
.steps li.late small { color: var(--i-stamp); }
.amount-box { text-align: right; padding-left: 1.5rem; border-left: 1px solid var(--i-rule); display: flex; flex-direction: column; min-width: 160px; }
.amount-lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--i-soft); font-weight: 600; }
.amount-val { font-size: 1.75rem; font-weight: 700; line-height: 1.1; margin: .1rem 0; }
.amount-when { font-size: .85rem; font-weight: 600; color: var(--i-ink); }
.track.overdue .amount-when { color: var(--i-stamp); }
.track.paid { background: #edf7f1; border-color: #bfe3cd; }
.track.paid .amount-when { color: #1f7a4d; }

/* ---- Items: zebra + highlighted total ---- */
.inv-items tbody tr:nth-child(even) td { background: #f7f8fb; }
.inv-items tfoot .grand td { background: #f4f6f9; }
.inv-items tfoot .grand td:first-child { border-radius: 4px 0 0 4px; }
.inv-items tfoot .grand td:last-child { border-radius: 0 4px 4px 0; }

/* ---- Payment card headers: icon + badge ---- */
.pay-opt h3 { display: flex; align-items: center; gap: .5rem; }
.pay-opt h3 .ico { display: inline-flex; width: 18px; height: 18px; }
.pay-opt h3 .ico svg { width: 18px; height: 18px; }
.badge { margin-left: auto; display: inline-flex; align-items: center; gap: .25rem; font-size: .65rem; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 999px; text-transform: uppercase; }
.badge svg { width: 11px; height: 11px; }
.badge-fast { background: #ffd666; color: #3d2e00; }
.badge-free { background: #c9ecd6; color: #124a2d; }
.pay-online { border-color: #1a9b63; box-shadow: 0 0 0 3px rgba(26,155,99,.12); }
.pay-online h3 { background: #157f51; }
.secure svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: .2rem; }
.secure::before { content: none; }
.fee-head { display: flex; align-items: center; gap: .3rem; font-weight: 600; color: var(--i-soft); margin: 0 0 .4rem !important; font-size: .74rem !important; text-transform: uppercase; letter-spacing: .04em; }
.fee-head svg { width: 13px; height: 13px; }

/* ---- Tooltips (hover on desktop, tap on touch) ---- */
.tip { display: inline-flex; vertical-align: -3px; width: 16px; height: 16px; padding: 0; border: 0; background: none; color: var(--i-soft); cursor: help; position: relative; }
.tip svg { width: 16px; height: 16px; }
.tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 240px; padding: .55rem .7rem; background: var(--i-ink); color: #fff; font: 400 .78rem/1.4 "Public Sans", system-ui, sans-serif; text-align: left; border-radius: 6px; box-shadow: 0 6px 20px rgba(31,42,92,.25); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 5; }
.tip::before { content: ""; position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--i-ink); opacity: 0; transition: opacity .12s; }
.tip:hover::after, .tip:hover::before, .tip:focus-visible::after, .tip:focus-visible::before, .tip.open::after, .tip.open::before { opacity: 1; }
.kv dt { display: flex; align-items: center; gap: .3rem; }

/* ---- Click to copy ---- */
.copy { display: inline-flex; align-items: center; gap: .35rem; cursor: copy; padding: .05rem .35rem; margin: -.05rem -.35rem; border-radius: 4px; transition: background .12s; position: relative; }
.copy svg { width: 13px; height: 13px; color: var(--i-soft); opacity: .6; }
.copy:hover { background: #eef1f4; }
.copy:hover svg { opacity: 1; }
.copy.copied { background: #c9ecd6; }
.copy.copied::after { content: "Copied"; position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); font-size: .7rem; font-weight: 600; background: #124a2d; color: #fff; padding: .15rem .45rem; border-radius: 4px; }
.ref-num .copy { justify-content: center; }

/* ---- Footer ---- */
.inv-foot { margin-top: 1.75rem; padding-top: 1rem; border-top: 1px solid var(--i-rule); display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; font-size: .85rem; color: var(--i-soft); }
.inv-foot a { color: var(--i-ink); font-weight: 500; }

@media (max-width: 640px) {
  .track { flex-direction: column; align-items: stretch; gap: 1rem; }
  .amount-box { border-left: 0; border-top: 1px solid var(--i-rule); padding: .75rem 0 0; text-align: left; }
  .steps li small { display: none; }
}
@media print {
  .track { background: none; border: 1px solid #999; }
  .copy svg, .tip { display: none; }
  .pay-online { box-shadow: none; }
  .badge { border: 1px solid #000; background: none; color: #000; }
  .inv-items tbody tr:nth-child(even) td { background: none; }
}
.pay-opt, .track { break-inside: avoid; }
.pay-btn:disabled { cursor: default; opacity: .55; transform: none; box-shadow: none; }
.preview-note { margin: 0 0 .6rem; font-size: .75rem; color: #8a5a00; background: #fff4d6; border: 1px dashed #e0b84a; padding: .35rem .5rem; border-radius: 4px; }
.inv-items .tip { margin-left: .15rem; }
.inv-items .tip::after { max-width: 300px; }
.fn-ref { display: none; font-size: .65em; color: var(--i-soft); margin-left: .15rem; }
.footnotes { display: none; margin: -1.25rem 0 2rem; padding-left: 1.4rem; font-size: .8rem; color: var(--i-soft); line-height: 1.45; }
.footnotes li { margin-bottom: .3rem; }
@media print { .fn-ref { display: inline; } .footnotes { display: block; } }
body.for-pdf .fn-ref { display: inline; } body.for-pdf .footnotes { display: block; }
.pay-paypal .pp-link { text-align: center; margin: .25rem 0 .3rem; }
.pay-btn-pp { --btn: #0070ba; --btn-dark: #005ea6; box-shadow: 0 2px 0 #004a85, 0 6px 16px rgba(0,112,186,.3); text-decoration: none; }
.pay-btn-pp:hover { box-shadow: 0 3px 0 #004a85, 0 10px 22px rgba(0,112,186,.35); }
.soft.center { text-align: center; margin: 0 0 .75rem; }
.pay-form { margin: .25rem 0 .5rem; display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.pay-form .pay-btn { margin-top: .35rem; }
.pay-btn-ach { --btn: #2f4bd6; --btn-dark: #2539ad; box-shadow: 0 2px 0 #1b2b86, 0 6px 16px rgba(47,75,214,.3); }
.pay-btn-ach:hover { box-shadow: 0 3px 0 #1b2b86, 0 10px 22px rgba(47,75,214,.35); }
.fee-line { margin: 0; font-size: .75rem; color: var(--i-soft); }
