/* ==================================================================
   Grant Manager — Pastel Partner-style Audit Print Presentation
   Monochrome (black & white) typographic presentation for financial
   statements, ledgers, vouchers, schedules and PDF/print output.

   Apply `.gm-audit` to the printable root (e.g. <body class="gm-audit">
   or <div class="gm-audit">) to get the classic audit report look:
   serif/fixed tabular figures, hairline rules, boxed totals, no fills.

   Screen preview keeps the active theme; print/PDF is always pure
   monochrome.
   ================================================================== */

/* ---- Base document ---- */
.gm-audit,
.gm-audit * {
  box-sizing: border-box;
}

.gm-audit {
  font-family: "Courier New", Courier, ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  background: #fff;
  color: #000;
  max-width: 100%;
}

html[data-theme="dark"] .gm-audit {
  background: var(--gm-surface, #2E3440);
  color: var(--gm-text, #ECEFF4);
}
html[data-theme="light"] .gm-audit {
  background: #fff;
  color: #000;
}

.gm-audit table,
.gm-audit th,
.gm-audit td {
  border: none;
}

/* ---- Report header / letterhead ---- */
.gm-audit .gm-audit-head,
.gm-audit .report-header,
.gm-audit .page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid #000;
}

html[data-theme="dark"] .gm-audit .gm-audit-head,
html[data-theme="dark"] .gm-audit .report-header,
html[data-theme="dark"] .gm-audit .page-header {
  border-bottom-color: #fff;
}

.gm-audit .gm-audit-org {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.gm-audit .gm-audit-doc-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.4rem 0;
}

.gm-audit .gm-audit-meta {
  font-size: 0.78rem;
  line-height: 1.55;
  text-align: right;
}
html[data-theme="dark"] .gm-audit .gm-audit-meta { color: var(--gm-text-muted, #9AA4B5); }

.gm-audit .gm-audit-period {
  font-size: 0.82rem;
  text-align: center;
  letter-spacing: 0.03em;
  margin-bottom: 1rem;
}

/* ---- Ledger / schedule tables ---- */
.gm-audit table.gm-audit-table,
.gm-audit .gm-audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0.5rem 0 1rem;
}

.gm-audit .gm-audit-table thead th,
.gm-audit .gm-audit-table th {
  text-align: left;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.5rem;
  border-bottom: 1.5px solid #000;
  white-space: nowrap;
}
html[data-theme="dark"] .gm-audit .gm-audit-table thead th,
html[data-theme="dark"] .gm-audit .gm-audit-table th {
  border-bottom-color: #fff;
  color: var(--gm-text, #ECEFF4);
}

.gm-audit .gm-audit-table tbody th,
.gm-audit .gm-audit-table tbody td {
  padding: 0.35rem 0.5rem;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px dotted #888;
}
html[data-theme="dark"] .gm-audit .gm-audit-table tbody td {
  border-bottom-color: var(--gm-border, #4C566A);
  color: var(--gm-text, #ECEFF4);
}

.gm-audit .gm-audit-table tbody tr:nth-child(even) {
  background: transparent;
}

/* ---- Amounts: right-aligned, monospaced ---- */
.gm-audit .gm-audit-table td.num,
.gm-audit .gm-audit-table th.num,
.gm-audit .gm-audit-num,
.gm-audit .amount-cell,
.gm-audit .amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Section / sub-total / totals ---- */
.gm-audit .gm-audit-section th,
.gm-audit .gm-audit-section td,
.gm-audit tr.gm-audit-section td {
  border-bottom: 1px solid #000;
  font-weight: 700;
}
html[data-theme="dark"] .gm-audit .gm-audit-section td,
html[data-theme="dark"] .gm-audit tr.gm-audit-section td {
  border-bottom-color: #fff;
}

.gm-audit tr.gm-audit-subtotal td,
.gm-audit .gm-audit-subtotal td,
.gm-audit .subtotal,
.gm-audit .totals-row {
  border-top: 1px solid #000;
  border-bottom: none;
  font-weight: 700;
}
html[data-theme="dark"] .gm-audit .gm-audit-subtotal td,
html[data-theme="dark"] .gm-audit .subtotal {
  border-top-color: #fff;
}

.gm-audit tr.gm-audit-total td,
.gm-audit .gm-audit-total td,
.gm-audit .grand-total,
.gm-audit .total-row-final {
  border-top: 2px solid #000;
  font-weight: 700;
  font-size: 0.9rem;
}
html[data-theme="dark"] .gm-audit .gm-audit-total td,
html[data-theme="dark"] .gm-audit .grand-total {
  border-top-color: #fff;
}

/* ---- Vouchers ---- */
.gm-audit .voucher,
.gm-audit .gm-voucher {
  border: 1.5px solid #000;
  padding: 0;
}
html[data-theme="dark"] .gm-audit .voucher,
html[data-theme="dark"] .gm-audit .gm-voucher {
  border-color: #fff;
}

.gm-audit .gm-voucher-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid #000;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
html[data-theme="dark"] .gm-audit .gm-voucher-head {
  border-bottom-color: #fff;
}

.gm-audit .gm-voucher-body {
  padding: 0.75rem;
}

.gm-audit .gm-voucher-field {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.8rem;
}
.gm-audit .gm-voucher-field .gm-voucher-label {
  font-weight: 700;
}

/* ---- Signature lines (sign-off) ---- */
.gm-audit .gm-audit-signatures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 2rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
}

.gm-audit .gm-signature {
  text-align: center;
  font-size: 0.78rem;
}
.gm-audit .gm-signature .gm-signature-line {
  border-top: 1px solid #000;
  margin-bottom: 0.35rem;
  padding-top: 0.35rem;
}
html[data-theme="dark"] .gm-audit .gm-signature .gm-signature-line {
  border-top-color: #fff;
}
.gm-audit .gm-signature .gm-signature-name {
  font-weight: 700;
}
.gm-audit .gm-signature .gm-signature-role {
  color: #555;
}
html[data-theme="dark"] .gm-audit .gm-signature .gm-signature-role {
  color: var(--gm-text-muted, #9AA4B5);
}

/* ---- Footer / page numbers ---- */
.gm-audit .gm-audit-foot,
.gm-audit .report-footer,
.gm-audit .page-footer {
  margin-top: 1.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #000;
  font-size: 0.72rem;
  display: flex;
  justify-content: space-between;
  color: #555;
}
html[data-theme="dark"] .gm-audit .gm-audit-foot,
html[data-theme="dark"] .gm-audit .report-footer {
  border-top-color: #fff;
  color: var(--gm-text-muted, #9AA4B5);
}

/* ==================================================================
   PRINT / PDF — force true monochrome.
   All fills flattened, all colors pure black on white.
   ================================================================== */
@page {
  size: A4 portrait;
  margin: 14mm 12mm;
}

@media print {
  html,
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .gm-audit,
  .gm-audit * {
    background: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
  }

  .gm-audit {
    max-width: none;
    font-size: 11px;
    line-height: 1.45;
  }

  .gm-audit a,
  .gm-audit a:visited {
    color: #000 !important;
    text-decoration: underline;
  }

  /* Flatten any accent fills used on screen */
  .gm-audit tr,
  .gm-audit td,
  .gm-audit th,
  .gm-audit div,
  .gm-audit span {
    background-color: #fff !important;
    background-image: none !important;
    color: #000 !important;
  }

  /* Suppress interactive chrome that is not part of the document */
  .gm-audit .no-print,
  .gm-audit .gm-toolbar,
  .gm-audit .gm-print-hidden,
  .no-print,
  .gm-toolbar,
  .navbar,
  .main-header,
  .main-sidebar,
  .control-sidebar,
  .gm-iframe-bar,
  .gm-iframe-tabs {
    display: none !important;
  }

  /* Page breaking */
  .gm-audit .gm-audit-table thead {
    display: table-header-group;
  }
  .gm-audit .gm-audit-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .gm-audit .gm-audit-break-before,
  .gm-audit .page-break {
    break-before: page;
    page-break-before: always;
  }
  .gm-audit tr.gm-audit-total td,
  .gm-audit .gm-audit-total td {
    break-before: avoid;
    page-break-inside: avoid;
  }

  .gm-audit .gm-audit-head,
  .gm-audit .report-header,
  .gm-audit .page-header {
    border-bottom: 2px solid #000 !important;
  }

  /* Preserve signature lines */
  .gm-audit .gm-signature .gm-signature-line {
    border-top: 1px solid #000 !important;
  }
}

/* ==================================================================
   Financial Position — screen A4 sheet
   The application controls remain outside this component. This sheet
   is deliberately plain and independent of the dark application card.
   ================================================================== */
@media screen {
  .gm-audit.financial-position-audit {
    width: 210mm;
    max-width: calc(100% - 2rem);
    min-height: 297mm;
    margin: 1.25rem auto 2rem;
    padding: 16mm 15mm;
    overflow: hidden;
    background: #fff !important;
    color: #17202a !important;
    border: 1px solid #c9ced4;
    border-radius: 2px;
    box-shadow: 0 3px 18px rgba(0, 0, 0, .18);
  }

  .gm-audit.financial-position-audit .gm-audit-head {
    border-bottom: 2px solid #17202a !important;
  }

  .gm-audit.financial-position-audit .gm-audit-org,
  .gm-audit.financial-position-audit .gm-audit-doc-title,
  .gm-audit.financial-position-audit .gm-audit-period,
  .gm-audit.financial-position-audit .gm-audit-meta,
  .gm-audit.financial-position-audit .gm-audit-table,
  .gm-audit.financial-position-audit .gm-audit-table th,
  .gm-audit.financial-position-audit .gm-audit-table td,
  .gm-audit.financial-position-audit .gm-audit-note {
    color: #17202a !important;
  }

  .gm-audit.financial-position-audit .gm-audit-meta {
    color: #59636d !important;
  }

  .gm-audit.financial-position-audit .gm-audit-table {
    table-layout: fixed;
    background: #fff !important;
    color: #17202a !important;
  }

  .gm-audit.financial-position-audit .gm-audit-table th,
  .gm-audit.financial-position-audit .gm-audit-table td,
  .gm-audit.financial-position-audit .gm-audit-table tbody tr,
  .gm-audit.financial-position-audit .gm-audit-table tbody tr:nth-child(even) {
    background: #fff !important;
  }

  .gm-audit.financial-position-audit .gm-audit-table th {
    white-space: normal;
    border-bottom-color: #17202a !important;
  }

  .gm-audit.financial-position-audit .gm-audit-table th:first-child,
  .gm-audit.financial-position-audit .gm-audit-table td:first-child {
    width: 58%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .gm-audit.financial-position-audit .gm-audit-table th.gm-audit-num,
  .gm-audit.financial-position-audit .gm-audit-table td.gm-audit-num {
    width: 21%;
    padding-left: .75rem;
    padding-right: .25rem;
    white-space: nowrap;
  }

  .gm-audit.financial-position-audit .gm-audit-table td {
    border-bottom-color: #9aa1a8 !important;
  }

  .gm-audit.financial-position-audit .gm-audit-table tr.gm-audit-section td {
    border-bottom-color: #17202a !important;
    padding-top: .8rem;
  }

  .gm-audit.financial-position-audit .gm-audit-table tr.gm-audit-total td {
    border-top-color: #17202a !important;
  }

  .gm-audit.financial-position-audit .gm-audit-note {
    margin-top: 1rem;
    color: #59636d !important;
    font-family: Arial, Helvetica, sans-serif;
    font-size: .75rem;
    line-height: 1.55;
  }
}

@media screen and (max-width: 800px) {
  .gm-audit.financial-position-audit {
    max-width: calc(100% - 1rem);
    min-height: 0;
    margin: .75rem auto 1rem;
    padding: 1.25rem;
  }

  .gm-audit.financial-position-audit .gm-audit-head {
    flex-direction: column;
  }

  .gm-audit.financial-position-audit .gm-audit-meta {
    text-align: left;
  }
}

@media print {
  .gm-audit.financial-position-audit {
    width: auto;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
