/* Accounting pages: lines tables, key figures, reports and print. */

/* screen-reader-only labels inside a scrolling table stay inside it (else they widen the page on phones) */
.table-responsive { position: relative; }

.acc-lines td { vertical-align: top; }
.acc-lines .form-control-sm, .acc-lines .form-select-sm { min-width: 6rem; }
.acc-lines .ui-col-account { min-width: 14rem; }
.acc-lines .ui-col-amount { width: 9rem; min-width: 8rem; }
.acc-lines .ui-col-qty { width: 6rem; }
.acc-lines .ui-col-dim { min-width: 9rem; }
.acc-lines .ui-col-remove { width: 2rem; text-align: center; }
.acc-lines input[type="number"] { text-align: right; }
.acc-line--removed { display: none; }
.acc-diff { font-weight: 500; }
.acc-lines-hint { margin: 0; padding: .5rem .75rem; border-bottom: 1px solid var(--bs-border-color); }
.acc-line-error td { border-top: 0; }
.acc-lines .ui-col-tax { width: 10rem; min-width: 8rem; }

/* expense page: totals under the lines */
.acc-exp-summary { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; padding: .75rem; border-top: 1px solid var(--bs-border-color); }
.acc-exp-summary dl { display: grid; grid-template-columns: auto auto; column-gap: 1.5rem; row-gap: .15rem; margin: 0; }
.acc-exp-summary dl > div { display: contents; }
.acc-exp-summary dt { font-weight: 400; color: var(--bs-secondary-color); text-align: right; }
.acc-exp-summary dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 8rem; }
.acc-exp-summary dl > div[hidden] { display: none; }
.acc-exp-summary__paid dt, .acc-exp-summary__paid dd { font-weight: 600; color: var(--bs-body-color); border-top: 1px solid var(--bs-border-color); padding-top: .25rem; }
.acc-exp-note svg { width: 1em; height: 1em; vertical-align: -.125em; }

.acc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; }
.acc-kpis--stack { grid-template-columns: 1fr; align-content: start; }
.acc-kpi { display: flex; flex-direction: column; gap: .15rem; padding: .75rem 1rem; background: #fff;
  border: 1px solid var(--ui-border); border-radius: .5rem; color: inherit; text-decoration: none; }
.acc-kpi span { font-size: .8rem; color: var(--ui-muted); }
.acc-kpi strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.acc-kpi { border-left: 3px solid var(--ui-section-line); }
.acc-kpi--pos { border-left-color: var(--ui-tone-success-solid); }
.acc-kpi--pos strong { color: var(--ui-tone-success-fg); }
.acc-kpi--neg { border-left-color: var(--ui-tone-danger-solid); }
.acc-kpi--neg strong { color: var(--ui-tone-danger-fg); }
a.acc-kpi:hover { border-color: var(--ui-section); }

.acc-summary { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: .75rem 1rem; background: #fff;
  border: 1px solid var(--ui-border); border-radius: .5rem; }
.acc-summary > div { display: flex; flex-direction: column; }
.acc-summary span { font-size: .8rem; color: var(--ui-muted); }
.acc-summary strong { font-variant-numeric: tabular-nums; }

.acc-report-head { margin: .25rem 0 .5rem; }
.acc-report td, .acc-report th { white-space: nowrap; }
.acc-report td.acc-col-text { white-space: normal; }
.acc-report .acc-col-amount, .acc-report .acc-col-balance, .acc-report .acc-col-percent, .acc-report .acc-col-number {
  text-align: right; font-variant-numeric: tabular-nums; }
.acc-row-heading td { font-weight: 600; background: var(--ui-section-soft); color: var(--ui-section-strong); text-transform: none; }
.acc-row-group td { font-weight: 600; }
.acc-row-subtotal td { font-weight: 600; border-top: 1px solid #cbd5e1; }
.acc-row-total td { font-weight: 700; border-top: 2px solid var(--ui-section); background: var(--ui-tone-neutral-bg); }
.acc-row-muted td { color: var(--ui-muted); font-style: italic; }
.acc-row-spacer td { border: 0; height: .75rem; }
.acc-print-only { display: none; }

/* printable document page */
.acc-print-page { background: #e5e7eb; }
.acc-print-toolbar { display: flex; gap: .5rem; justify-content: center; padding: .75rem; }
.acc-print-sheet { max-width: 210mm; margin: 0 auto 2rem; padding: 14mm; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.acc-print-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid #111827; padding-bottom: .75rem; margin-bottom: 1rem; }
.acc-print-company { font-size: 1.25rem; font-weight: 700; }
.acc-print-title { font-size: 1.1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.acc-print-draft { color: var(--ui-tone-danger-fg); font-weight: 700; }
.acc-print-party { margin-bottom: 1rem; }
.acc-print-table th, .acc-print-table td { font-size: .9rem; }
.acc-print-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; margin-top: 3.5rem; }
.acc-print-signatures div { border-top: 1px solid #111827; padding-top: .35rem; font-size: .85rem; }
.acc-print-signatures span { color: #374151; }
.acc-print-blocked { display: none; }

/* IRD (CBMS) status badges */
.acc-sync { font-weight: 600; border: 1px solid transparent; }
.acc-sync--pending { background: var(--ui-tone-warning-bg); color: var(--ui-tone-warning-fg); border-color: var(--ui-tone-warning-line); }
.acc-sync--failed { background: var(--ui-tone-danger-bg); color: var(--ui-tone-danger-fg); border-color: var(--ui-tone-danger-line); }
.acc-sync--sent { background: var(--ui-tone-success-bg); color: var(--ui-tone-success-fg); border-color: var(--ui-tone-success-line); }
.acc-sync--not_required { background: var(--ui-tone-neutral-bg); color: var(--ui-tone-neutral-fg); border-color: var(--ui-tone-neutral-line); }

@media print {
  @page { margin: 12mm; }
  .ui-sidebar, .ui-topbar, .ui-pagebar__actions, .acc-noprint, .ui-toasts, .ui-panel__actions { display: none !important; }
  .ui-main { margin: 0 !important; padding: 0 !important; }
  .ui-content { padding: 0 !important; }
  body, .ui-app, .acc-print-page { background: #fff !important; }
  .ui-panel { border: 0 !important; box-shadow: none !important; }
  .acc-print-only { display: block; }
  .acc-print-sheet { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .acc-report td, .acc-report th { font-size: 10pt; padding: .15rem .35rem; }
  a { color: inherit !important; text-decoration: none !important; }
  .table-responsive { overflow: visible !important; }
  /* a tax invoice prints only through its Print button, which counts the print and sets the copy label */
  .acc-print-counted:not(.acc-print-recorded) .acc-print-sheet { display: none !important; }
  .acc-print-counted:not(.acc-print-recorded) .acc-print-blocked { display: block; padding: 2rem; font-size: 14pt; }
}

@media (max-width: 575.98px) {
  .acc-kpis { grid-template-columns: repeat(2, 1fr); }
  .acc-print-sheet { padding: 6mm; }
  .acc-print-head { flex-direction: column; }
  .acc-print-head .text-end { text-align: left !important; }
}
