/* =====================================================================
   print.css -- how a report looks on paper (and in Save as PDF).

   Loaded last. Everything that changes the look is inside @media print, so
   the screen is untouched; the two helper classes at the top are the only
   screen rules, and they only hide things.

   The page: a letterhead (client's name, GSTIN, PAN, state) on the left and
   the report's name and date on the right, over a navy rule with an amber
   line under it; ledger-style tables (a light band between navy rules for
   the column headings, hairlines between rows, a single rule above and a
   double rule under totals); the date printed and "Page x of y" at the foot.
   Colour is limited to the navy rules and the amber line, so a black-and-
   white laser printer loses nothing: every meaning is also in words.

   Raw colour values are allowed here because paper is always white -- the
   theme tokens follow the screen's light/dark choice, paper must not.
   The wrapper itself (letterhead, footer, signature block) is built by
   printWrap() in index.html.
   ===================================================================== */

.print-only { display: none; }

@media print {
  :root {
    --pr-navy:  #0E1E3A;
    --pr-amber: #C8741E;
    --pr-ink:   #141B26;
    --pr-ink2:  #4A5566;
    --pr-faint: #7A8596;
    --pr-rule:  #D5DBE3;
    --pr-band:  #EDF0F5;
    --pr-group: #F5F6F8;
  }
  @page {
    size: A4;
    margin: 11mm 10mm 13mm;
    @bottom-right { content: "Page " counter(page) " of " counter(pages);
                    font: 7.5pt "Segoe UI", Arial, sans-serif; color: #7A8596; }
  }

  /* the band fills and rules print without "Background graphics" ticked */
  html, body, body * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .no-print, .pr-hide { display: none !important; }
  .print-only { display: inline !important; }

  body.printing {
    font-family: "Segoe UI", Inter, Arial, sans-serif;
    color: #141B26; background: #fff !important;
    font-size: 9pt; line-height: 1.4;
  }
  body.printing #main, body.printing #content, body.printing #app {
    border: none !important; box-shadow: none !important; border-radius: 0 !important;
    background: #fff !important; padding: 0 !important; margin: 0 !important; max-width: none !important;
  }
  body.printing #content * { box-shadow: none !important; text-shadow: none !important; }

  body.printing table.printwrap, body.printing table.printwrap > * > tr > td { background: #fff !important; }

  /* ---------- letterhead ---------- */
  body.printing .print-head {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 18px;
    text-align: left; padding: 0 0 6px; margin: 0 0 12px;
    border-bottom: 2px solid #0E1E3A; position: relative;
  }
  body.printing .print-head::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -5px;
    border-bottom: 1px solid #C8741E;
  }
  body.printing .print-head .ph-left { min-width: 0; }
  body.printing .print-head .ph-co {
    font-family: Cambria, Georgia, "Times New Roman", serif;
    font-size: 17pt; font-weight: 700; color: #0E1E3A; line-height: 1.15; letter-spacing: 0.01em;
  }
  body.printing .print-head .ph-id { font-size: 7.8pt; color: #4A5566; margin-top: 3px; }
  body.printing .print-head .ph-right { text-align: right; flex: none; max-width: 55%; }
  body.printing .print-head .ph-title {
    font-family: Cambria, Georgia, "Times New Roman", serif;
    font-size: 12.5pt; font-weight: 700; color: #0E1E3A;
    text-transform: uppercase; letter-spacing: 0.1em; margin: 0;
  }
  body.printing .print-head .ph-sub { font-size: 9pt; font-weight: 600; color: #141B26; margin-top: 1px; }
  body.printing .print-head .ph-period { font-size: 8.5pt; color: #141B26; margin-top: 1px; }
  body.printing .print-head .ph-note { font-size: 7.2pt; color: #7A8596; margin-top: 1px; }

  /* ---------- footer (repeats on every page) ---------- */
  body.printing .print-foot {
    display: flex; justify-content: space-between; gap: 12px;
    border-top: 0.8px solid #0E1E3A; margin-top: 12px; padding-top: 3px;
    font-size: 7.2pt; color: #7A8596;
  }
  body.printing .print-foot b { color: #4A5566; font-weight: 600; }

  /* ---------- signature block (Balance Sheet, P&L, Trial Balance) ---------- */
  body.printing .print-sign {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-top: 34px; font-size: 8.5pt; color: #4A5566;
    break-inside: avoid; page-break-inside: avoid;
  }
  body.printing .print-sign .ps-r { text-align: center; color: #141B26; }
  body.printing .print-sign .ps-line {
    margin-top: 38px; border-top: 0.8px solid #141B26; padding-top: 2px; width: 200px;
  }

  /* ---------- the screen's furniture comes off ---------- */
  body.printing .section, body.printing details.section, body.printing .card,
  body.printing .table-wrap, body.printing .tally {
    border: none !important; border-radius: 0 !important; background: #fff !important;
    padding: 0 !important; margin: 0 0 12px !important;
  }
  body.printing #printBody div[style*="overflow"] {
    border: none !important; border-radius: 0 !important; overflow: visible !important; background: none !important;
  }
  /* a form field is a control: with its box hidden, its label goes too */
  body.printing .field:has(> input, > select, > textarea, > .searchbox) { display: none !important; }
  body.printing .stat::before, body.printing .stat::after { display: none !important; }
  body.printing .help, body.printing .help-pop, body.printing .searchbox,
  body.printing .empty, body.printing .empty-state, body.printing .btn,
  body.printing #icMsg, body.printing #alMsg { display: none !important; }
  body.printing a, body.printing a:visited { color: inherit !important; text-decoration: none !important; }
  /* badges and pills read as plain words */
  body.printing .tag, body.printing .pill, body.printing .badge, body.printing .chip,
  body.printing td span[style*="border-radius"] {
    border: none !important; background: none !important; padding: 0 !important;
    color: #141B26 !important; font: inherit !important; font-size: inherit !important;
    text-transform: capitalize; border-radius: 0 !important;
  }
  body.printing tr[style*="opacity"] { opacity: 1 !important; }
  body.printing .rowbad, body.printing .rowbad td, body.printing tr.bad td { background: none !important; }
  body.printing .hint { color: #7A8596 !important; font-size: 7.6pt; }
  body.printing .mono { font-family: inherit; }
  body.printing [style*="color:var(--fig-red)"], body.printing [style*="color: var(--fig-red)"] { color: #141B26 !important; }

  /* section headings inside a report: small capitals in navy */
  body.printing .section h3 {
    font-size: 8.4pt !important; font-weight: 700; color: #0E1E3A !important;
    text-transform: uppercase; letter-spacing: 0.08em;
    margin: 4px 0 5px !important; padding: 0 0 2px; border-bottom: 1px solid #C8741E;
  }
  body.printing .section h3 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }

  /* ---------- summary tiles become one ruled strip ---------- */
  body.printing .kpi-grid, body.printing .grid:has(> .stat) {
    display: flex !important; gap: 0 !important; flex-wrap: nowrap;
    border: 1px solid #0E1E3A; margin: 0 0 10px !important; padding: 0 !important;
  }
  body.printing .kpi, body.printing .grid > .stat {
    flex: 1 1 0; display: block !important; min-width: 0;
    background: #fff !important; border: none !important; border-radius: 0 !important;
    border-left: 0.6px solid #D5DBE3 !important; padding: 4px 8px !important; margin: 0 !important;
  }
  body.printing .kpi:first-child, body.printing .grid > .stat:first-child { border-left: none !important; }
  body.printing .kpi::before, body.printing .kpi::after { display: none !important; }
  body.printing .kpi-k, body.printing .stat .k {
    display: block; font-size: 6.6pt !important; letter-spacing: 0.08em; text-transform: uppercase;
    color: #7A8596 !important; font-weight: 600; margin: 0 !important;
  }
  body.printing .kpi-v, body.printing .stat .v {
    display: block; font-size: 10.5pt !important; font-weight: 700; color: #141B26 !important;
    font-variant-numeric: tabular-nums; margin: 0 !important; line-height: 1.3;
  }
  body.printing .kpi-s { display: block; font-size: 6.8pt !important; color: #7A8596 !important; }
  /* label, figure, note -- whatever order the screen drew them in */
  body.printing .kpi { display: flex !important; flex-direction: column; }
  body.printing .kpi .kpi-k { order: 1; } body.printing .kpi .kpi-v { order: 2; } body.printing .kpi .kpi-s { order: 3; }

  /* ---------- plain tables: Day Book, Outstanding, MSME, Group P&L, Inter-company ---------- */
  body.printing #printBody table {
    width: 100%; border-collapse: collapse; font-size: 8.4pt;
    font-variant-numeric: tabular-nums; background: #fff !important;
  }
  body.printing #printBody table thead th {
    background: #EDF0F5 !important; color: #0E1E3A !important;
    border-top: 1px solid #0E1E3A !important; border-bottom: 1.4px solid #0E1E3A !important;
    font-size: 6.9pt !important; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    padding: 4px 6px !important; vertical-align: bottom; white-space: nowrap;
    position: static !important;
  }
  body.printing #printBody table tbody td {
    border: none !important; border-bottom: 0.6px solid #D5DBE3 !important;
    padding: 2.6px 6px !important; vertical-align: top; background: #fff !important;
    color: #141B26;
  }
  body.printing #printBody table tbody tr:nth-child(even) td { background: #fff !important; }
  body.printing #printBody table td.right, body.printing #printBody table th.right { white-space: nowrap; }
  body.printing #printBody table tfoot td, body.printing #printBody table tfoot tr {
    font-weight: 700; background: #fff !important;
    border-top: 1px solid #141B26 !important; border-bottom: 2.6px double #141B26 !important;
    padding: 3px 6px !important;
  }
  /* a report's total prints once, at its end -- not at the foot of every page */
  body.printing #printBody table tfoot { display: table-row-group !important; }
  body.printing .pr-nw { white-space: nowrap !important; }
  body.printing #printBody tr { break-inside: avoid; page-break-inside: avoid; }

  /* Group P&L: section bands, gross and net profit ruled */
  body.printing #printBody tr.secrow td {
    background: #F5F6F8 !important; color: #0E1E3A; font-size: 7.4pt;
    text-transform: uppercase; letter-spacing: 0.06em; padding-top: 4px !important;
  }
  body.printing #printBody tr.gtot td { border-top: 1px solid #141B26 !important; font-weight: 700; }
  body.printing #printBody tr.gnet td { border-bottom: 2.6px double #141B26 !important; }

  /* ---------- Tally-form statements: Balance Sheet, P&L, Trial Balance, Ledger ---------- */
  body.printing .tally { font-size: 8.6pt !important; font-variant-numeric: tabular-nums; color: #141B26; }
  body.printing .tally .trow { padding: 2px 6px !important; border-bottom: 0.6px solid #D5DBE3; }
  body.printing .tally .cols { border: none !important; }
  body.printing .tally .trow.tgrp[style*="--tally-colhead"],
  body.printing .tally .trow.tgrp[style*="--fig-sky"] {
    background: #EDF0F5 !important; color: #0E1E3A !important;
    border-top: 1px solid #0E1E3A !important; border-bottom: 1.4px solid #0E1E3A !important;
    font-size: 6.9pt !important; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  }
  body.printing .tally .tgrp { background: #F5F6F8 !important; font-weight: 700; border-top: none; }
  body.printing .tally .tgrp-body .tled, body.printing .tally .tled { color: #4A5566 !important; }
  body.printing .tally .tgrp-body .trow > div:first-child { padding-left: 8px; }
  body.printing .tally .tsum { font-weight: 700; background: #fff !important;
    border-top: 0.9px solid #141B26 !important; border-bottom: 0.6px solid #D5DBE3 !important; }
  body.printing .tally .grand { font-weight: 700; background: #fff !important;
    border-top: 1px solid #141B26 !important; border-bottom: 2.6px double #141B26 !important; }
  body.printing .tally .tprofit { font-weight: 700; }
  body.printing .tally .side.left { border-right: 1px solid #0E1E3A !important; }
  body.printing .tally .cols { display: flex !important; align-items: stretch; }
  body.printing .tally .side { display: flex !important; flex-direction: column; }
  body.printing .tally .side > .grand { margin-top: auto; }
  body.printing .tally .trow .amt, body.printing .tally .trow .amt2 { white-space: nowrap; }
  body.printing .tally [style*="background:var(--tally-band)"] { background: #fff !important; font-style: italic; }
  body.printing .tally-meta:not(.tally-who) { font-size: 7.6pt; color: #4A5566 !important; padding: 2px 0 4px; }

  /* the ledger account: the screen's wide fixed columns made "Particulars"
     a sliver on A4; on paper the figures take only what they need */
  body.printing .tally .trow[style*="90px 1fr 88px 76px"] { grid-template-columns: 76px 1fr 56px 58px 84px 84px 104px !important; }
  body.printing .tally .trow[style*="90px 1fr 90px 80px"] { grid-template-columns: 76px 1fr 60px 62px 92px 92px !important; }
  body.printing .tally .trow[style*="1fr 115px 115px 130px"] { grid-template-columns: 1fr 84px 84px 104px !important; }
  body.printing .tally .trow[style*="1fr 120px 120px"] { grid-template-columns: 1fr 92px 92px !important; }
  body.printing .tally .trow[style*="grid-template-columns:90px 1fr;"] { grid-template-columns: 76px 1fr !important; }
  body.printing #lvBox .tally .trow { column-gap: 6px; }
  body.printing .lvblk { break-inside: avoid; page-break-inside: avoid; }
  body.printing .lvblk > .trow[style*="padding:0"] { display: none; }
  body.printing .lvblk > .trow:first-child { border-bottom: none; }
  body.printing .lvblk > .trow.tled { border-bottom: none; padding-top: 0 !important; padding-bottom: 0 !important; font-size: 7.8pt; }
  body.printing .lvblk { border-bottom: 0.6px solid #D5DBE3; }
}
