/* The printed report. Loaded last: print rules use !important to beat every screen style.
   Goes with: js/ui/print.js. */
/* A printout is a report of every page: light colors whatever the screen
   mode, values instead of form boxes, no controls, and each section kept on
   one page where it fits. main.js draws every page before printing. */

.print-date,
.print-brand {
  display: none;
}
@page {
  margin: 0.45in;
}
@media print {
  :root {
    --bg: #fff !important;
    --card: #fff !important;
    --ink: #2d1a17 !important;
    --ink2: #4f3d38 !important;
    --mute: #6e5a55 !important;
    --line: #e2d3cd !important;
    --soft: #f6ede9 !important;
    --good: #2f6b44 !important;
    --amber: #8a6206 !important;
    --over: #b8281d !important;
    --warn: #b8281d !important;
    --goodbg: #eaf0e8 !important;
    --warnbg: #f7eee7 !important;
    --sh: none !important;
    color-scheme: light !important;   /* a dark scheme would print a dark page edge */
  }
  html,
  body {
    background: #fff !important;
    color: var(--ink);
  }

  /* not printed */
  .noprint,
  .hicons,
  #menubtn,
  .drawer,
  .drawer-scrim,
  .help,
  #scrim,
  #toast,
  #update-bar,
  #save-state,
  .stickytop,
  .wibar,
  .viewseg,
  .filterbar,
  .hero .hero-filters,
  #tracker-range,
  .band-edge,
  .page-links,
  .page-name,
  header::before,
  header .htxt::before,
  #setup,
  #stub-card,
  #bank-card,
  .dzpriv,
  .x,
  [data-add],
  [data-txdel],
  [data-impundo],
  input[type=range] {
    display: none !important;
  }

  /* header and banner: plain text, no brown band */
  header,
  .hero {
    position: static !important;
    background: none !important;
    box-shadow: none !important;
    clip-path: none !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--ink) !important;
  }
  header {
    display: block !important;
  }
  header h1 {
    margin: 0 !important;
    font-size: 30px !important;
    font-weight: 800 !important;
    letter-spacing: -.02em;
    line-height: 1.1;
    color: var(--ink) !important;
  }
  header .tag {
    display: none !important;
  }
  .print-brand {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 3px solid #8f5d54;
    font-size: 13px;
    font-weight: 750;
    letter-spacing: -.01em;
    color: #8f5d54;
  }
  .print-brand img {
    width: 16px;
    height: auto;
  }
  .print-date {
    display: block;
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--mute);
  }
  .hero {
    display: block !important;
    margin: 16px 0 6px !important;
    padding: 16px 20px !important;
    border: 1px solid var(--line) !important;
    border-radius: 16px !important;
    background: var(--soft) !important;
    break-inside: avoid;
  }
  .hero .hero-label,
  .hero .hero-sub,
  .hero .hero-chip,
  .hero .hero-value {
    color: var(--ink) !important;
    background: none !important;
    box-shadow: none !important;
  }
  .hero .hero-label {
    margin: 0 !important;
    font-size: 13px !important;
    font-weight: 600;
    color: var(--ink2) !important;
  }
  .hero .hero-value {
    margin: 2px 0 4px !important;
    font-size: 36px !important;
    font-weight: 800;
    letter-spacing: -.02em;
  }
  .hero .hero-sub {
    font-size: 13px !important;
    color: var(--ink2) !important;
  }
  .hero .hero-chip {
    display: inline-block;
    margin-right: 8px;
    padding: 2px 10px !important;
    border-radius: 999px;
    background: #fff !important;
    border: 1px solid var(--line);
    font-weight: 650;
    color: var(--ink) !important;
  }

  /* every page, one after another, each with its name */
  .panel {
    display: block !important;
    padding: 0 !important;
    background: none !important;
  }
  .panel.off {
    display: none !important;
  }
  /* The page's name sits inside its summary cards (set by nav.js), which
     never split, so a heading can't be left alone at the bottom of a sheet.
     Safari on iPhone ignores "keep with next" on headings. */
  .panel .kpis::before {
    content: attr(data-label);
    grid-column: 1 / -1;
    display: block;
    margin: 12px 0 0;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--ink);
    font-size: 18px;
    font-weight: 750;
    color: var(--ink);
  }

  /* Summary cards: a fixed number per row so they pair up on any device,
     4 in a row, or 3 when a page has 6. */
  .kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 0 0 12px !important;
  }
  .kpis:has(> .kpi:nth-child(6)) {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .kpi {
    padding: 11px 12px !important;
    border-radius: 14px !important;
    box-shadow: none !important;
  }
  .kpi .v {
    font-size: 20px !important;
  }
  /* Paycheck calendar: 4 months in a row, 3 rows, on any device */
  .cal {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .cal .m {
    padding: 9px 11px !important;
  }
  .grid2,
  .grid3 {
    display: block !important;
  }

  /* sections stay on one page where they fit; rows never split */
  .card,
  .kpi,
  .kpis,
  .mbox,
  .lst,
  .row2,
  .cal .m,
  .glance-rings .r,
  .glance-bars > div {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .card {
    margin: 0 0 12px !important;
    border: 1px solid var(--line) !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  .card h2,
  .card h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* form fields read as plain values */
  input,
  select {
    -webkit-appearance: none !important;
    appearance: none !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    outline: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    color: var(--ink) !important;
    -webkit-text-fill-color: var(--ink) !important;
  }
  select {
    width: auto !important;
    min-width: max-content !important;   /* show the whole choice, e.g. "Avalanche: highest interest first" */
    max-width: none !important;
    background-image: none !important;
  }
  input::placeholder {
    color: transparent !important;
  }
  input::-webkit-calendar-picker-indicator {
    display: none !important;
  }
  .row2 {
    grid-template-columns: minmax(0,1fr) auto !important;
  }
  .row2 > :last-child,
  .row2 select,
  .row2 input {
    justify-self: end;
    text-align: right;
  }
  .money,
  .money input {
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .money::before {
    display: none !important;   /* the printed amount carries its own currency sign */
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    transition: none !important;
    animation: none !important;
  }
}
