.psr, .psr-report {
  --bg: #f1f3f5; --panel: #ffffff; --ink: #1f2933; --muted: #6b7785; --line: #cfd6dd;
  --accent: #1f5f99; --accent-ink: #ffffff; --band: #e8edf2; --danger: #b3261e; --ok-bg: #fff7d6;
  color: var(--ink); font: 13px/1.35 Calibri, "Segoe UI", system-ui, sans-serif;
}
.psr *, .psr-report * { box-sizing: border-box; }
body.psr-report-page { margin: 0; background: #fff; }
.psr .app { max-width: 1500px; margin: 0 auto; padding: 0 16px 16px; }
.psr .toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
}
.psr .toolbar h1 { margin: 0 0 0 auto; font-size: 16px; font-weight: 600; }
.psr button,
.psr .btn,
.psr select,
.psr input[type="date"] {
  font: inherit; color: inherit;
}
.psr button,
.psr .btn {
  border: 1px solid var(--line); background: var(--panel);
  padding: 5px 14px; border-radius: 4px; cursor: pointer; text-decoration: none;
}
.psr button:hover,
.psr .btn:hover { border-color: var(--accent); }
.psr button:focus-visible,
.psr .btn:focus-visible,
.psr select:focus-visible,
.psr input:focus-visible,
.psr .pick-list:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.psr #btnPreview { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.psr .top {
  display: grid; gap: 10px;
  grid-template-columns: 6.4fr 1.6fr 7.1fr;
}
.psr .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  margin: 0; padding: 10px 12px; min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.psr .panel .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.psr .panel label { display: inline-flex; align-items: center; gap: 5px; }
.psr .tag {
  background: var(--ok-bg); border: 1px solid var(--line); border-radius: 3px;
  padding: 3px 10px; font-weight: 600;
}
.psr .tag.block { display: block; }
.psr select,
.psr input[type="date"] {
  border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; background: #fff;
}
.psr .panel select { width: 100%; }
.psr .two-col { flex-direction: row; gap: 18px; }
.psr .two-col .col { display: flex; flex-direction: column; gap: 7px; }
.psr .lists {
  display: grid; gap: 10px; margin-top: 10px;
  grid-template-columns: 6.4fr 8.8fr;
  grid-template-areas: "sizes papers" "gsms accounts";
}
.psr .area-sizes { grid-area: sizes; }
.psr .area-papers { grid-area: papers; }
.psr .area-gsms { grid-area: gsms; }
.psr .area-accounts { grid-area: accounts; }
.psr .list-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  display: flex; flex-direction: column; min-width: 0;
}
.psr .list-box header {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; background: var(--band); border-bottom: 1px solid var(--line);
  border-radius: 6px 6px 0 0; font-weight: 600;
}
.psr .list-box .count { color: var(--muted); font-weight: 400; }
.psr .list-box .mini { margin-left: auto; display: flex; gap: 4px; }
.psr .list-box .mini button { padding: 1px 8px; font-size: 12px; }
.psr .pick-list {
  height: 300px; overflow: auto; padding: 4px 0;
  position: relative;
}
.psr .pick-list.loading { opacity: .5; }
.psr .pick-item {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 10px; cursor: pointer; border-bottom: 1px solid #eef1f4;
}
.psr .pick-item:hover { background: #f3f7fb; }
.psr .hint { color: var(--muted); margin: 10px 2px 0; }
.psr kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px;
  padding: 0 4px; background: #1f2933; font-size: 11px;
}
.psr #status { min-height: 20px; margin-top: 6px; color: var(--muted); }
.psr #status.error { color: var(--danger); font-weight: 600; }
@media (max-width: 1000px) {
  .psr .top { grid-template-columns: 1fr; }
  .psr .two-col { flex-wrap: wrap; }
  .psr .lists { grid-template-columns: 1fr; grid-template-areas: "sizes" "gsms" "papers" "accounts"; }
  .psr .pick-list { height: 220px; }
}

/* report */
.psr-report { padding: 12px 16px 24px; max-width: 1400px; margin: 0 auto; }
.psr-report .actions { display: flex; gap: 8px; margin-bottom: 10px; }
.psr-report .errors {
  background: #fdecea; border: 1px solid #f3b8b3; color: #7a1c14;
  border-radius: 6px; padding: 12px 16px; max-width: 720px;
}
.psr-report .errors ul { margin: 6px 0 0; padding-left: 20px; }
.psr-report .rpt-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.psr-report .rpt-head .logo { max-height: 64px; }
.psr-report .rpt-head .company { font-size: 18px; font-weight: 700; }
.psr-report .rpt-head .title { font-size: 15px; font-weight: 600; }
.psr-report .rpt-head .period { color: var(--muted); }
.psr-report.fmt-report .rpt-head { justify-content: center; text-align: center; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.psr-report.fmt-grid .rpt-head .company { font-size: 14px; }
.psr-report table.ledger { width: 100%; border-collapse: collapse; background: var(--panel); }
.psr-report table.ledger th,
.psr-report table.ledger td { padding: 3px 8px; border-bottom: 1px solid #e3e8ee; vertical-align: top; }
.psr-report table.ledger thead th {
  background: var(--band); text-align: left; border-bottom: 2px solid var(--line);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}

.psr-report .a4-header,
.psr-report .company-header-img-wrap {
    text-align: center;
}

    .psr-report .a4-header img,
    .psr-report .company-header-img {
        display: block;
        margin: 0 auto; /* centres the image; text-align can't */
        width: 100%; /* fills the same width as the tables */
        max-width: 180mm; /* never wider than the printable area */
        height: auto; /* keeps the aspect ratio */
    }


.psr-report .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.psr-report .nowrap { white-space: nowrap; }
.psr-report .neg { color: var(--danger); }
.psr-report tr.hdr td { font-weight: 700; background: #f4f6f8; border-top: 1px solid var(--line); }
.psr-report tr.hdr.lvl0 td { font-size: 14px; background: #dfe7ef; text-decoration: underline; }
.psr-report tr.hdr.lvl1 td { padding-left: 18px; }
.psr-report tr.hdr.lvl2 td { padding-left: 30px; font-style: italic; }
.psr-report tr.hdr.lvl3 td { padding-left: 42px; }
.psr-report tr.hdr.lvl4 td { padding-left: 54px; font-weight: 600; }
.psr-report tr.ob td { color: var(--muted); font-style: italic; }
.psr-report tr.summary td { font-weight: 600; }
.psr-report tr.total td { font-weight: 700; background: #f3effa; border-top: 1px solid var(--line); }
.psr-report tr.total.lvl4 td { background: #f8f6fc; }
.psr-report tr.total.grand td { background: #fbeaea; font-size: 14px; border-top: 2px solid var(--ink); }

/* print */


@page { size: A4 landscape; margin: 10mm; }

@media print {
  .noprint { display: none !important; }
  body.psr-report-page { background: #fff; font-size: 10.5px; }
  .psr-report { max-width: none; padding: 0; }
  table.ledger thead { display: table-header-group; }
  table.ledger thead th { position: static; }
  table.ledger tr { page-break-inside: avoid; }
  tr.hdr { page-break-after: avoid; }
  tr.hdr td, tr.total td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
