/* ============================================================
   base.css — reset, document defaults, typography, focus.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  text-wrap: balance;
}
h1 { font-size: var(--text-page-title); letter-spacing: -.01em; }
h2 { font-size: var(--text-section); }
h3 { font-size: var(--text-subhead); }

p { margin: 0 0 var(--space-md); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled {
  cursor: not-allowed;
  opacity: .55;
}

code, kbd, pre, .mono {
  font-family: var(--font-mono);
  font-size: .92em;
}
code {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}

/* Figures line up in columns everywhere in an accounting app. */
.right, .amt, .amt2, td.num, .tabular {
  font-variant-numeric: tabular-nums;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}

/* ---------- focus: always visible, never only on mouse ---------- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
/* Inputs and buttons get a ring instead of an outline so the shape reads. */
.btn:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.searchbox:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

/* ---------- utilities ---------- */
.hidden { display: none !important; }
.right  { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Secondary/help text. Used 206 times across the existing screens. */
.hint {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  margin-top: var(--space-xs);
}

::selection {
  background: var(--color-primary-soft);
  color: var(--text-primary);
}

/* ---------- scrollbars: slim, unobtrusive ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border: 3px solid var(--color-bg);
  border-radius: var(--radius-pill);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   PRINT / SAVE AS PDF
   The page prints as a REPORT, not as a screenshot of the app:
   no navigation, no controls, black figures on white paper,
   and no row ever split across a page boundary. The colour
   tokens are forced back to the light palette in tokens.css,
   so printing from night mode gives the identical document.
   ============================================================ */
@media print {
  @page { size: A4; margin: 12mm 11mm; }

  /* everything that is an app, not a report */
  #side, .topbar, .tabbar, .btn, .fy-bar .field, .fy-bar .tabbar,
  .searchbox, .toast-stack, .drawer, .drawer-scrim, .modal, .modal-scrim,
  .crumbs, #navToggle, .dash-gate, .comenu, .dropdown,
  input, select { display: none !important; }
  /* the toolbar holds only controls; with them hidden it printed as an
     empty rounded box, so it does not print at all */
  .fy-bar { display: none !important; }

  html, body { background: #fff !important; }
  #app { display: block; }
  #main { padding: 0 !important; max-width: none; margin: 0; }
  #content { padding: 0; }

  .section { border: none; box-shadow: none; padding: 0; }

  /* the report itself: hairline black rules, full width */
  .tally {
    border: 1px solid #000;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    font-size: 11px;
  }
  .tally .thead { background: #fff !important; color: #000 !important;
                  border-bottom: 2px solid #000; }
  .trow, tr { break-inside: avoid; page-break-inside: avoid; }
  .tsum  { border-top: 1px solid #000; border-bottom: 1px solid #000; }
  .tally .grand { border-top: 2px solid #000; }
  .tally .side.left { border-right: 1px solid #000; }

  /* plain tables (Day Book, Outstanding, ledgers) */
  table { font-size: 11px; width: 100%; }
  th, td { padding: 3px 6px; }
  thead { display: table-header-group; }   /* column headers repeat per page */
  tfoot { display: table-footer-group; }

  /* a link on paper is just text */
  a, a:visited { color: #000 !important; text-decoration: none !important; }
  .tag { border: 1px solid #000; background: #fff !important; color: #000 !important; }

  /* scroll containers must not clip the printout */
  .table-wrap, .section, div[style*="overflow-x"] {
    overflow: visible !important; max-height: none !important;
  }
}
