/* Reports module. Chart palette validated for contrast and colour-blind separation (light and dark sets).
   c1 brand orange · c2 blue · c3 teal · c4 purple · c5 amber · neutral grey (de-emphasised: non-billable, other)
   ok / bad are status colours (met / missed) and are never used as series colours. */
:root {
  --rp-c1: #FF4100; --rp-c2: #1F5FA8; --rp-c3: #138A78; --rp-c4: #7A4FB8; --rp-c5: #B07800;
  --rp-neutral: #B4B4AC; --rp-ok: #2F8A3E; --rp-bad: #C8321F;
  --rp-r1: #2F8A3E; --rp-r2: #7DAA3C; --rp-r3: #D19A00; --rp-r4: #C8321F;
  --rp-grid: #E6E6E1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --rp-c1: #E8541C; --rp-c2: #4A86D8; --rp-c3: #2FA37A; --rp-c4: #A57BD8; --rp-c5: #C08A1E;
    --rp-neutral: #6B706E; --rp-ok: #5DB36B; --rp-bad: #E5554A;
    --rp-r1: #5DB36B; --rp-r2: #9CC461; --rp-r3: #E0B040; --rp-r4: #E5554A;
    --rp-grid: #343938;
  }
}

/* ---------- home ---------- */
.rp-group { margin-bottom: 1.75rem; }
.rp-group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .6rem; }
.rp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .9rem; }
.rp-cardlink { display: flex; gap: .9rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.05rem 1.15rem; color: var(--ink); text-decoration: none !important; border-top: 3px solid transparent; transition: border-color .15s, background .15s; }
.rp-cardlink:hover { border-top-color: var(--brand); background: var(--surface-2); }
.rp-cardicon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); color: var(--brand-strong); flex: none; border: 1px solid var(--line); }
.rp-cardtext { display: flex; flex-direction: column; gap: .2rem; }
.rp-cardtext strong { font-weight: 600; }
.rp-cardtext span { font-size: .85rem; color: var(--muted); line-height: 1.45; }
.rp-panel-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.rp-panel-links .btn { padding: .35rem .7rem; font-size: .82rem; }

/* ---------- report header & filters ---------- */
.rp-head h1 { margin-bottom: .2rem; }
.rp-head .muted { max-width: 70ch; }
.rp-period { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem !important; }
.rp-pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; padding: .2rem .65rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.rp-pill strong { color: var(--ink); font-weight: 600; }
.rp-pill .icon { width: 14px; height: 14px; }
.rp-pill-period { color: var(--ink); font-weight: 600; border-color: var(--brand); }
.rp-filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; align-items: flex-end; gap: .6rem .75rem; margin-bottom: 1.25rem; }
.rp-f { display: flex; flex-direction: column; gap: .2rem; margin: 0; min-width: 0; }
.rp-f > span { font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.rp-f select { width: auto; max-width: 220px; padding: .42rem .55rem; font-size: .87rem; }
.rp-f input[type=date] { width: 9.6rem; padding: .38rem .5rem; font-size: .87rem; }
.rp-f-actions { flex-direction: row; align-items: center; gap: .8rem; margin-left: auto; }
.rp-f-actions .btn { padding: .45rem .9rem; }

/* ---------- stat tiles ---------- */
.rp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem; }
.rp-tile { background: var(--surface); padding: .95rem 1.1rem; display: flex; flex-direction: column; gap: .1rem; min-width: 0; border-top: 3px solid transparent; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.rp-tile-label { font-size: .78rem; font-weight: 500; color: var(--muted); }
.rp-tile strong { font-size: 1.65rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rp-tile small { color: var(--muted); font-size: .76rem; line-height: 1.35; }
.rp-tile-good { border-top-color: var(--ok); } .rp-tile-good strong { color: var(--ok); }
.rp-tile-warn { border-top-color: #F2A000; } .rp-tile-warn strong { color: var(--warn); }
.rp-tile-bad { border-top-color: var(--brand); } .rp-tile-bad strong { color: var(--bad); }

/* ---------- layout ---------- */
.rp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.rp-wide { grid-column: 1 / -1; }
.rp-card { min-width: 0; }
.rp-card .card-head h2 { font-size: 1rem; }
.rp-count { display: inline-block; font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 0 .4rem; vertical-align: middle; margin-left: .2rem; }
.rp-csv { font-size: .82rem; font-weight: 600; }
.rp-chart-body { min-width: 0; }
.rp-chart-note { margin: .5rem 0 0; }
.rp-note { margin: .25rem 0; max-width: 90ch; }
.rp-more { margin: .6rem 0 0; }
.rp-empty { display: grid; place-items: center; min-height: 140px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: .9rem; text-align: center; padding: 1rem; }
.rp-empty p { margin: 0; }
.rp-pick h2 { margin-bottom: .4rem; }
.rp-pick-form { display: flex; gap: .6rem; justify-content: center; margin-top: 1rem; }
.rp-pick-form select { max-width: 320px; }
.rp-sign { margin-top: 1.5rem; padding-top: .8rem; border-top: 1px solid var(--line); color: var(--muted); }

/* ---------- tables ---------- */
.rp-table td.wrap { min-width: 220px; max-width: 420px; overflow-wrap: anywhere; }
.rp-table td.num, .rp-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table td.nowrap { white-space: nowrap; }
.rp-table td.ref-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-table td.ref-cell a { font-weight: 600; }
.rp-tone { font-weight: 600; }
.rp-tone-ok { color: var(--ok); } .rp-tone-warn { color: var(--warn); } .rp-tone-bad { color: var(--bad); }

/* ---------- charts ---------- */
.rp-svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.rp-svg .grid { stroke: var(--rp-grid); stroke-width: 1; }
.rp-svg .baseline { stroke: var(--line); stroke-width: 1; }
.rp-svg .axis { fill: var(--muted); font-size: 11px; }
.rp-svg .label { fill: var(--ink); font-size: 12px; }
.rp-svg .val { fill: var(--ink); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rp-svg .center-val { fill: var(--ink); font-size: 26px; font-weight: 600; }
.rp-svg .mark { stroke: none; }
.rp-svg .mark:hover { opacity: .82; }
.rp-svg .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.rp-svg .dot { stroke: var(--surface); stroke-width: 2; }
.rp-svg .track { fill: none; stroke: var(--surface-2); stroke-width: 26; }
.rp-svg .arc { fill: none; stroke-width: 26; }
.rp-svg .c1, .rp-key.c1 { fill: var(--rp-c1); background: var(--rp-c1); }
.rp-svg .c2, .rp-key.c2 { fill: var(--rp-c2); background: var(--rp-c2); }
.rp-svg .c3, .rp-key.c3 { fill: var(--rp-c3); background: var(--rp-c3); }
.rp-svg .c4, .rp-key.c4 { fill: var(--rp-c4); background: var(--rp-c4); }
.rp-svg .c5, .rp-key.c5 { fill: var(--rp-c5); background: var(--rp-c5); }
.rp-svg .neutral, .rp-key.neutral { fill: var(--rp-neutral); background: var(--rp-neutral); }
.rp-svg .ok, .rp-key.ok { fill: var(--rp-ok); background: var(--rp-ok); }
.rp-svg .bad, .rp-key.bad { fill: var(--rp-bad); background: var(--rp-bad); }
.rp-svg .r-awesome, .rp-key.r-awesome { fill: var(--rp-r1); background: var(--rp-r1); }
.rp-svg .r-good, .rp-key.r-good { fill: var(--rp-r2); background: var(--rp-r2); }
.rp-svg .r-average, .rp-key.r-average { fill: var(--rp-r3); background: var(--rp-r3); }
.rp-svg .r-poor, .rp-key.r-poor { fill: var(--rp-r4); background: var(--rp-r4); }
.rp-svg .line.c1, .rp-svg .arc.c1 { stroke: var(--rp-c1); fill: none; }
.rp-svg .line.c2, .rp-svg .arc.c2 { stroke: var(--rp-c2); fill: none; }
.rp-svg .line.c3, .rp-svg .arc.c3 { stroke: var(--rp-c3); fill: none; }
.rp-svg .line.c4, .rp-svg .arc.c4 { stroke: var(--rp-c4); fill: none; }
.rp-svg .line.c5, .rp-svg .arc.c5 { stroke: var(--rp-c5); fill: none; }
.rp-svg .arc.neutral { stroke: var(--rp-neutral); fill: none; }
.rp-svg .arc.r-awesome { stroke: var(--rp-r1); fill: none; } .rp-svg .arc.r-good { stroke: var(--rp-r2); fill: none; }
.rp-svg .arc.r-average { stroke: var(--rp-r3); fill: none; } .rp-svg .arc.r-poor { stroke: var(--rp-r4); fill: none; }
.rp-legend { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; padding: 0; margin: .7rem 0 0; font-size: .82rem; color: var(--ink); }
.rp-legend li { display: inline-flex; align-items: center; gap: .4rem; }
.rp-legend b { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-key { display: inline-block; width: 11px; height: 11px; border-radius: 3px; flex: none; }
.rp-donut { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 1.25rem; align-items: center; }
.rp-donut .rp-legend { flex-direction: column; gap: .45rem; margin: 0; }
.rp-donut .rp-legend li { justify-content: space-between; gap: .5rem; }
.rp-donut .rp-legend li span { flex: 1; }

/* ---------- printed header (hidden on screen except the customer report's cover band) ---------- */
.rp-print-head { display: none; align-items: center; gap: 1rem; padding: 0 0 .9rem; margin-bottom: 1.2rem; border-bottom: 3px solid var(--brand); }
.rp-print-head.rp-show { display: flex; background: var(--surface); border: 1px solid var(--line); border-bottom: 3px solid var(--brand); border-radius: var(--radius); padding: 1rem 1.25rem; }
.rp-print-head img { width: 52px; height: 52px; border-radius: 4px; flex: none; }
.rp-ph-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.rp-ph-brand { font-size: .72rem; font-weight: 700; letter-spacing: .5em; color: var(--brand-strong); }
.rp-ph-text strong { font-size: 1.35rem; font-weight: 600; line-height: 1.25; }
.rp-ph-text span { font-size: .85rem; color: var(--muted); }
.rp-ph-filters { font-size: .78rem !important; }
.rp-ph-meta { font-size: .78rem; color: var(--muted); text-align: right; white-space: nowrap; }
.rp-customer .rp-head h1 { display: none; }
.rp-customer .rp-head .muted { display: none; }

@media (max-width: 1000px) { .rp-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .rp-donut { grid-template-columns: 1fr; justify-items: center; }
  .rp-f select, .rp-f input[type=date] { max-width: none; width: 100%; }
  .rp-f { flex: 1 1 45%; }
  .rp-f-actions { margin-left: 0; }
  .rp-print-head.rp-show { flex-wrap: wrap; }
  .rp-ph-meta { text-align: left; }
}

/* ---------- print / Save as PDF: white A4, Techn22 header, no navigation ---------- */
@media print {
  @page { size: A4; margin: 12mm 11mm 14mm; }
  :root {
    --brand-strong: #CC3400; --ink: #1B201F; --paper: #fff; --surface: #fff; --surface-2: #F5F5F2; --line: #D6D6D0; --muted: #5E5E58;
    --ok: #2F7D3B; --ok-bg: #E5F2E6; --warn: #8A5A00; --warn-bg: #FFF1D6; --bad: #B3261E; --bad-bg: #FCE4E2;
    --blue: #1F5FA8; --blue-bg: #E3EDF9; --purple: #6A3FA0; --purple-bg: #EEE7F7;
    --rp-c1: #FF4100; --rp-c2: #1F5FA8; --rp-c3: #138A78; --rp-c4: #7A4FB8; --rp-c5: #B07800;
    --rp-neutral: #B4B4AC; --rp-ok: #2F8A3E; --rp-bad: #C8321F; --rp-r1: #2F8A3E; --rp-r2: #7DAA3C; --rp-r3: #D19A00; --rp-r4: #C8321F; --rp-grid: #E6E6E1;
    color-scheme: light;
  }
  html { font-size: 12px; }
  body { background: #fff !important; color: var(--ink); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sidebar, .topbar, .flash, .skip, .rp-filters, .head-actions, .btn, .rp-csv, .rp-noprint, .crumbs, .rp-pick-form { display: none !important; }
  .has-shell { display: block; }
  .shell { display: block; }
  main { padding: 0 !important; max-width: none !important; }
  a { color: inherit !important; text-decoration: none !important; }
  .rp-print-head, .rp-print-head.rp-show { display: flex !important; background: none; border: 0; border-bottom: 3px solid var(--brand); border-radius: 0; padding: 0 0 3mm; margin-bottom: 4mm; }
  .rp-head { margin-bottom: 3mm; }
  .rp-head h1 { display: none; }
  .rp-head .muted { display: none; }
  .rp-period { margin-top: 0 !important; }
  .rp-pill-period { display: none; }
  .rp-tiles { break-inside: avoid; grid-template-columns: repeat(auto-fit, minmax(30mm, 1fr)); margin-bottom: 4mm; }
  .rp-tile { padding: 2.5mm 3mm; }
  .rp-tile strong { font-size: 1.45rem; }
  .rp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 4mm; }
  .card { border-color: var(--line); padding: 3mm 4mm; margin-bottom: 4mm; box-shadow: none; }
  .rp-chart { break-inside: avoid; page-break-inside: avoid; }
  .rp-table-card { break-inside: auto; }
  .rp-table-card .card-head { break-after: avoid; page-break-after: avoid; }
  .table-wrap { overflow: visible !important; border: 0; }
  .table { font-size: .86rem; }
  .table th, .table td { padding: 1.6mm 2mm; }
  .table thead { display: table-header-group; }
  .table tr { break-inside: avoid; page-break-inside: avoid; }
  .table tbody tr:hover { background: none; }
  .rp-table { font-size: .78rem; }
  .rp-table th { white-space: normal; font-size: .72rem; }
  .rp-table th, .rp-table td { padding: 1.4mm 1.5mm; }
  .rp-table td.nowrap { white-space: normal; }
  .rp-table td.wrap { min-width: 32mm; max-width: none; overflow-wrap: normal; word-break: normal; }
  .rp-table .tag, .rp-table .rating { font-size: .68rem; padding: .05rem .3rem; }
  .rp-legend { font-size: .82rem; }
  .rp-donut { grid-template-columns: 42mm 1fr; gap: 4mm; }
  .rp-chart-body .rp-svg { max-height: 95mm; }
  .rp-note, .rp-sign { break-inside: avoid; }
  .rp-empty { min-height: 0; padding: 4mm; }
}
