/*
 * Serepok — document view (invoice, donation receipt).
 * Built on the serepok-variables.css tokens so light and dark both follow the
 * theme, and so an operator's colour choices in the Content Manager carry over.
 * Print rules live at the bottom: on paper the document is the only thing that
 * should survive - no navigation, no breadcrumb, no sidebar.
 */

.sp-doc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: var(--ui-gutter-base, 24px);
}

@media (max-width: 991px) {
    .sp-doc-layout { grid-template-columns: minmax(0, 1fr); }
}

.sp-card {
    background: var(--ui-block-bg, #fff);
    border: var(--ui-block-border, 1px solid rgba(15, 23, 42, .08));
    border-radius: var(--ui-block-border-radius-lg, 18px);
    box-shadow: var(--ui-block-shadow, 0 6px 18px rgba(15, 23, 42, .05));
}

.sp-doc { padding: clamp(24px, 3vw, 40px); }
.sp-doc + .sp-doc { margin-top: var(--ui-block-spacing-base, 20px); }

/* head ------------------------------------------------------------------ */
.sp-doc__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.sp-doc__brand { display: block; margin-bottom: 18px; }
.sp-doc__brand img { max-height: 46px; width: auto; }
.sp-doc__brand .logo-dark { display: none; }
body.dark-mode .sp-doc__brand .logo-light { display: none; }
body.dark-mode .sp-doc__brand .logo-dark { display: inline-block; }
.sp-doc__brand-name { margin: 0; font-size: var(--font-size-h4, 20px); font-weight: 700; }

.sp-doc__eyebrow {
    display: block;
    margin-bottom: 4px;
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}

.sp-doc__title {
    margin: 0;
    font-size: clamp(24px, 3vw, var(--font-size-h2, 32px));
    font-weight: var(--font-weight-black, 900);
    line-height: 1.15;
}

.sp-doc__headside { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.sp-doc__amount { font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; font-variant-numeric: tabular-nums; }

/* status pill ----------------------------------------------------------- */
.sp-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1.5px solid currentColor;
    font-size: var(--font-size-md, 14px);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.sp-pill i { font-size: 1em; }
.sp-pill[data-status="paid"], .sp-pill[data-status="received"], .sp-pill[data-status="active"] { color: var(--text-success-color, #27b85a); }
.sp-pill[data-status="unpaid"], .sp-pill[data-status="pending"], .sp-pill[data-status="processing"] { color: var(--text-warning-color, #f59f00); }
.sp-pill[data-status="canceled"], .sp-pill[data-status="declined"], .sp-pill[data-status="collections"] { color: var(--text-danger-color, #e5484d); }
.sp-pill[data-status="refunded"], .sp-pill[data-status="draft"], .sp-pill[data-status="payment-pending"] { color: var(--text-info-color, #0ea5e9); }

/* facts ----------------------------------------------------------------- */
.sp-doc__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
}

.sp-doc__facts > div { min-width: 0; }
.sp-doc__facts small {
    display: block;
    margin-bottom: 2px;
    font-size: var(--font-size-sm, 12px);
    font-weight: 600;
    color: var(--text-secondary-lighter-color, #6b7280);
}
.sp-doc__facts strong { font-size: var(--font-size-md, 14px); font-weight: 700; }

/* note ------------------------------------------------------------------ */
.sp-note {
    display: flex;
    gap: 14px;
    margin-top: 24px;
    padding: 16px 18px;
    border-radius: var(--ui-block-border-radius, 12px);
    border: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    background: var(--ui-block-bg-form, #fff);
    line-height: var(--line-height-md, 1.55);
}

.sp-note > i { margin-top: 3px; font-size: 18px; color: var(--text-secondary-lighter-color, #6b7280); }
.sp-note--ok { border-color: color-mix(in srgb, var(--text-success-color, #27b85a) 40%, transparent); }
.sp-note--ok > i { color: var(--text-success-color, #27b85a); }
.sp-note--bad { border-color: color-mix(in srgb, var(--text-danger-color, #e5484d) 40%, transparent); }
.sp-note--bad > i { color: var(--text-danger-color, #e5484d); }
.sp-note--info { border-color: color-mix(in srgb, var(--text-info-color, #0ea5e9) 40%, transparent); }
.sp-note--info > i { color: var(--text-info-color, #0ea5e9); }

/* parties --------------------------------------------------------------- */
.sp-doc__parties {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    margin-top: 28px;
}

@media (max-width: 575px) { .sp-doc__parties { grid-template-columns: minmax(0, 1fr); } }

.sp-doc__party > strong {
    display: block;
    margin-bottom: 8px;
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}

.sp-doc__party address {
    margin: 0;
    font-style: normal;
    line-height: var(--line-height-md, 1.55);
}

/* sections and tables ---------------------------------------------------- */
.sp-doc__section-title {
    margin: 32px 0 12px;
    font-size: var(--font-size-sm, 12px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}

.sp-table-shell {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    border-radius: var(--ui-block-border-radius, 12px);
}

.sp-table { width: 100%; margin: 0; border-collapse: collapse; }
.sp-table th, .sp-table td { padding: 14px 18px; text-align: left; vertical-align: top; }
.sp-table thead th {
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
    border-bottom: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    white-space: nowrap;
}
.sp-table tbody tr + tr td { border-top: 1px solid var(--ui-block-secondary-divider-border-color, rgba(15, 23, 42, .06)); }
.sp-table th.sp-table__num,
.sp-table td.sp-table__num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-table tfoot th {
    border-top: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    font-size: var(--font-size-md, 14px);
    font-weight: 800;
    color: inherit;
    letter-spacing: 0;
    text-transform: none;
}

/* totals: one right edge, a single rule above the total ------------------- */
.sp-doc__totals {
    margin: 18px 0 0 auto;
    width: min(360px, 100%);
}

.sp-doc__totals > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    padding: 8px 18px;
}

.sp-doc__totals > div > span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.sp-doc__totals .is-total {
    margin-top: 6px;
    padding-top: 14px;
    border-top: 2px solid var(--ui-block-border-color, rgba(15, 23, 42, .12));
    font-size: var(--font-size-lg, 16px);
}
.sp-doc__totals .is-total > span { font-weight: 800; }

.sp-doc__taxnote { margin: 10px 0 0; font-size: var(--font-size-sm, 12px); color: var(--text-secondary-lighter-color, #6b7280); }

/* side ------------------------------------------------------------------- */
.sp-doc-side { display: grid; gap: var(--ui-block-spacing-base, 20px); }
.sp-side-card { padding: var(--ui-block-padding-lg, 24px); }
.sp-side-card__eyebrow {
    display: block;
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}
.sp-side-card__amount { margin: 6px 0 16px; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sp-side-card__amount--sm { font-size: 22px; }
.sp-side-card__label { display: block; margin-bottom: 6px; font-weight: 600; }
.sp-side-card .form-control { width: 100%; }
.sp-side-card .payment-form { margin-top: 14px; }
.sp-side-card .payment-form .btn { width: 100%; }
.sp-side-card__hint { margin: 6px 0 0; font-size: var(--font-size-sm, 12px); color: var(--text-secondary-lighter-color, #6b7280); }

.sp-actions { padding: 0; overflow: hidden; }
.sp-actions__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px var(--ui-block-padding-lg, 24px);
    border-bottom: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    font-weight: 700;
}
.sp-actions__head i { color: var(--primary, #4f56d9); }
.sp-actions__list { display: flex; flex-direction: column; }
.sp-actions__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px var(--ui-block-padding-lg, 24px);
    color: inherit;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.sp-actions__link + .sp-actions__link { border-top: 1px solid var(--ui-block-secondary-divider-border-color, rgba(15, 23, 42, .06)); }
.sp-actions__link i { width: 18px; text-align: center; color: var(--ui-icon-color, #6b7280); }
.sp-actions__link:hover, .sp-actions__link:focus {
    background: var(--ui-nav-link-active-bg, rgba(79, 86, 217, .1));
    color: var(--primary, #4f56d9);
    text-decoration: none;
}
.sp-actions__link:hover i, .sp-actions__link:focus i { color: inherit; }

/* print ------------------------------------------------------------------ */
@media print {
    body { background: #fff !important; }
    .sp-print-hide,
    .mtd-breadcrumb,
    .mtd-global-page-header,
    .sp-doc-side,
    header.header,
    .header-main,
    .navbar,
    #header,
    #footer,
    .footer,
    .mtd-footer,
    .cc-window,
    .partners,
    .mtd-partners,
    .wbams-powered-by,
    .back-to-top { display: none !important; }
    .sp-doc-layout { display: block; }
    .sp-card { box-shadow: none !important; border-color: #ddd !important; }
    .sp-doc { padding: 0; border: 0; }
    .sp-pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sp-table-shell { overflow: visible; }
    .sp-doc__section-title { break-after: avoid; }
    .sp-table { break-inside: auto; }
    .sp-table tr { break-inside: avoid; }

    /* Paper is white whatever the screen was: a dark-mode document printed as
       light text on an unprinted background comes out blank. */
    body.dark-mode {
        --ui-block-bg: #ffffff;
        --ui-block-bg-form: #ffffff;
        --ui-block-border-color: #dddddd;
        --ui-block-secondary-divider-border-color: #eeeeee;
        --text-secondary-body-color: #333333;
        --text-secondary-lighter-color: #555555;
        --text-secondary-faded-color: #666666;
        --ui-icon-color: #555555;
        background: #ffffff !important;
        color: #111111 !important;
    }
    body.dark-mode .sp-doc,
    body.dark-mode .sp-doc h1,
    body.dark-mode .sp-doc h2,
    body.dark-mode .sp-doc a,
    body.dark-mode .sp-doc address,
    body.dark-mode .sp-doc strong,
    body.dark-mode .sp-doc th,
    body.dark-mode .sp-doc td,
    body.dark-mode .sp-doc span:not(.sp-pill):not(.sp-pill *) { color: #111111 !important; }
    body.dark-mode .sp-doc__eyebrow,
    body.dark-mode .sp-doc__facts small,
    body.dark-mode .sp-doc__party > strong,
    body.dark-mode .sp-doc__section-title,
    body.dark-mode .sp-table thead th { color: #555555 !important; }
    body.dark-mode .sp-doc__brand .logo-light { display: inline-block !important; }
    body.dark-mode .sp-doc__brand .logo-dark { display: none !important; }
    body.dark-mode.gray_logos .sp-doc__brand img { filter: none !important; }
}

/* ------------------------------------------------------------------ */
/* The invoice as a document (invoice.tpl .sp-inv): the business in a   */
/* band in the site's colour, the facts in one strip, the lines with    */
/* what is said of each (who did it, a discount), the totals, and how   */
/* it was paid. Its colours follow the site's scheme, and dark mode.    */
.sp-inv {
    --inv-accent: var(--mtd-scheme-primary, var(--primary, #b0532a));
    --inv-accent-soft: color-mix(in srgb, var(--inv-accent) 9%, #ffffff);
    --inv-ok: #1f7a4a;
    --inv-ok-soft: color-mix(in srgb, #2f9e62 13%, #ffffff);
    --inv-ink: #1d1b22;
    --inv-muted: #6a6470;
    --inv-line: rgba(29, 27, 34, .1);
    --inv-soft: #faf8f9;
    color: var(--inv-ink);
}
body.dark-mode .sp-inv {
    --inv-accent: color-mix(in srgb, var(--mtd-scheme-primary, #b0532a) 70%, #ffffff);
    --inv-accent-soft: color-mix(in srgb, var(--mtd-scheme-primary, #b0532a) 20%, #17131a);
    --inv-ok: #8fdcb0;
    --inv-ok-soft: rgba(47, 158, 98, .16);
    --inv-ink: #f3eef1;
    --inv-muted: #b6aab2;
    --inv-line: rgba(255, 255, 255, .1);
    --inv-soft: rgba(255, 255, 255, .03);
}
.sp-doc.sp-inv { padding: 0; overflow: hidden; }
/* (Serepok's dark mode gives every paragraph, cell and list item one colour, with !important: the invoice's ink is that
   colour here, and its accents and quieter words keep theirs) */
body.dark-mode .sp-inv { --mtd-text: var(--inv-ink); }
body.dark-mode .sp-inv .sp-inv__facts-amount dd, body.dark-mode .sp-inv .sp-inv__grand dd { color: var(--inv-accent) !important; }
body.dark-mode .sp-inv .sp-inv__saved { color: var(--inv-ok) !important; }
body.dark-mode .sp-inv .sp-inv__table > thead > tr > th { background: none !important; }
body.dark-mode .sp-inv .sp-inv__table > thead > tr > th, body.dark-mode .sp-inv .sp-inv__thanks, body.dark-mode .sp-inv .sp-inv__taxnote,
body.dark-mode .sp-inv .sp-inv__payment-none, body.dark-mode .sp-inv .sp-inv__totals dt { color: var(--inv-muted) !important; }

.sp-inv__band {
    position: relative; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
    padding: 36px 40px 28px; background: linear-gradient(135deg, var(--inv-accent-soft), transparent 72%);
    border-bottom: 1px solid var(--inv-line);
}
.sp-inv__band::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
    background: linear-gradient(90deg, var(--inv-accent), color-mix(in srgb, var(--inv-accent) 45%, #ffffff));
}
.sp-inv__logo { margin: 0; }
.sp-inv__logo img { max-height: 58px; }
.sp-inv__payto { margin: 12px 0 0; font-style: normal; font-size: 13px; line-height: 1.6; color: var(--inv-muted); }
.sp-inv__heading { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; }
.sp-inv__eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--inv-accent); }
.sp-inv__number { margin: 0; font-size: clamp(26px, 3.2vw, 36px); font-weight: 800; letter-spacing: -.015em; line-height: 1.1; color: var(--inv-ink); }

.sp-inv__facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0;
    background: var(--inv-soft); border-bottom: 1px solid var(--inv-line);
}
.sp-inv__facts > div { padding: 16px 24px; border-left: 1px solid var(--inv-line); min-width: 0; }
.sp-inv__facts > div:first-child { border-left: 0; padding-left: 40px; }
.sp-inv__facts dt { margin: 0 0 5px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--inv-muted); }
.sp-inv__facts dd { margin: 0; font-size: 15px; font-weight: 700; color: var(--inv-ink); }
.sp-inv__facts-amount dd { font-size: 18px; color: var(--inv-accent); font-variant-numeric: tabular-nums; }

.sp-inv__parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; padding: 28px 40px 6px; }
.sp-inv__party h2, .sp-inv__payments h2 {
    margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--inv-muted);
}
.sp-inv__party address, .sp-inv__party p { margin: 0; font-style: normal; font-size: 14px; line-height: 1.65; color: var(--inv-ink); }

.sp-inv__items { padding: 22px 40px 0; }
.sp-inv .sp-inv__table { width: 100%; margin: 0; border-collapse: collapse; background: none; }
.sp-inv .sp-inv__table > thead > tr > th {
    padding: 0 0 10px; border: 0; border-bottom: 2px solid var(--inv-ink); background: none; text-align: left;
    font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--inv-muted);
}
.sp-inv .sp-inv__table > tbody > tr > td {
    padding: 15px 0; border: 0; border-top: 1px solid var(--inv-line); background: none; vertical-align: top;
    font-size: 15px; font-weight: 600; color: var(--inv-ink);
}
.sp-inv .sp-inv__table > tbody > tr:first-child > td { border-top: 0; }
.sp-inv .sp-inv__table > tbody > tr > td:first-child, .sp-inv .sp-inv__table > thead > tr > th:first-child { padding-left: 0; }
.sp-inv .sp-inv__table > tbody > tr > td.sp-inv__num, .sp-inv .sp-inv__table > thead > tr > th.sp-inv__num { padding-left: 16px; padding-right: 0; }
.sp-inv .bill-line-note { display: block; margin-top: 4px; font-size: 12.5px; font-weight: 500; line-height: 1.45; color: var(--inv-muted); }
.sp-inv .sp-inv__num, .sp-inv .sp-inv__table > thead > tr > th.sp-inv__num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.sp-inv__summary {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 330px); gap: 24px; align-items: start;
    margin: 0 40px; padding: 18px 0 4px; border-top: 2px solid var(--inv-ink);
}
.sp-inv__summary-notes { display: grid; gap: 10px; align-content: start; }
.sp-inv__saved {
    justify-self: start; display: inline-flex; align-items: center; gap: 9px; margin: 0; padding: 10px 15px; border-radius: 12px;
    background: var(--inv-ok-soft); color: var(--inv-ok); font-size: 14px; font-weight: 700;
}
.sp-inv__taxnote { margin: 0; font-size: 12px; color: var(--inv-muted); }
.sp-inv__totals { display: grid; gap: 9px; margin: 0; }
.sp-inv__totals > div { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.sp-inv__totals dt { font-weight: 600; color: var(--inv-muted); }
.sp-inv__totals dd { margin: 0; font-weight: 600; color: var(--inv-ink); font-variant-numeric: tabular-nums; }
.sp-inv__totals .sp-inv__grand { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--inv-line); align-items: baseline; }
.sp-inv__grand dt { font-size: 16px; font-weight: 800; color: var(--inv-ink); }
.sp-inv__grand dd { font-size: 24px; font-weight: 800; color: var(--inv-accent); }

.sp-inv__payments { margin: 28px 40px 0; padding: 18px 22px; border: 1px solid var(--inv-line); border-radius: 16px; background: var(--inv-soft); }
.sp-inv__payment-list { list-style: none; margin: 0; padding: 0; }
.sp-inv__payment-list li { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
.sp-inv__payment-list li + li { border-top: 1px solid var(--inv-line); }
.sp-inv__payment-icon {
    flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--inv-ok-soft); color: var(--inv-ok); font-size: 13px;
}
.sp-inv__payment-what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-inv__payment-what strong { font-size: 14px; color: var(--inv-ink); }
.sp-inv__payment-what small { font-size: 12.5px; color: var(--inv-muted); overflow-wrap: anywhere; }
.sp-inv__payment-list .sp-inv__num { font-weight: 700; color: var(--inv-ink); }
.sp-inv__payment-none { color: var(--inv-muted); font-size: 14px; }
.sp-inv__balance {
    display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 6px; padding-top: 12px;
    border-top: 1px dashed var(--inv-line); font-size: 15px; font-weight: 700; color: var(--inv-ink);
}
.sp-inv__balance em {
    margin-left: 10px; padding: 3px 11px; border-radius: 999px; background: var(--inv-ok-soft); color: var(--inv-ok);
    font-size: 12px; font-style: normal; font-weight: 700; vertical-align: 1px;
}
.sp-inv__balance strong { font-variant-numeric: tabular-nums; }
.sp-inv__thanks { margin: 0; padding: 26px 40px 32px; text-align: center; font-size: 14px; color: var(--inv-muted); }

@media (max-width: 680px) {
    .sp-inv__band { flex-direction: column; padding: 30px 22px 22px; }
    .sp-inv__heading { align-items: flex-start; text-align: left; }
    .sp-inv__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sp-inv__facts > div, .sp-inv__facts > div:first-child { padding: 14px 22px; border-left: 0; border-top: 1px solid var(--inv-line); }
    .sp-inv__facts > div:nth-child(-n+2) { border-top: 0; }
    .sp-inv__facts > div:nth-child(even) { border-left: 1px solid var(--inv-line); }
    .sp-inv__parties { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 22px 22px 4px; }
    .sp-inv__items { padding: 18px 22px 0; }
    .sp-inv__summary { grid-template-columns: minmax(0, 1fr); margin: 0 22px; }
    .sp-inv__summary-notes { order: 2; }
    .sp-inv__payments { margin: 22px 22px 0; padding: 14px 16px; }
    .sp-inv__thanks { padding: 22px; }
}
@media print {
    .sp-inv { --inv-soft: transparent; }
    .sp-inv__band { background: none; }
}
