/* The Report tab (views/reports.js) and its charts (views/charts.js). Replaces reports.css. Colours, sizes and corners come from
   tokens.css only; .tile, .tile-h, .kpis, .kpi and .stack are in frame.css. */

.reports { padding: 20px 24px 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.rp-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rp-head h1 { margin: 0; font-size: var(--fs-title); font-weight: 650; letter-spacing: -.01em; }
.rp-period { position: relative; display: inline-flex; align-items: center; margin-left: auto; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--panel); color: var(--mute); }
.rp-period svg { display: none; }
.rp-period select { appearance: none; border: 0; background: transparent; font: inherit; font-size: var(--fs-body); color: var(--text); padding-right: 22px; height: 100%; cursor: pointer; }
.rp-period::after { content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid var(--mute); border-bottom: 1.5px solid var(--mute); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.rp-period:focus-within { border-color: var(--acc); }

.rp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.rp-kpi { gap: 2px; min-width: 0; }
.rp-kpi-ring { flex-direction: row; align-items: center; gap: 14px; }
.rp-kpi-ring > span:last-child { display: grid; gap: 2px; }
.rp-of { color: var(--dim); font-size: var(--fs-lead); }
.rp-kpi.is-alert .kpi-v { color: var(--bad); }

.rp-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.rp-progress { grid-column: span 8; }
.rp-weeks { grid-column: span 4; }
.rp-status, .rp-overdue { grid-column: span 6; }
.rp-card { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-content: start; }
.rp-card .tile-h { margin: 0; flex-wrap: wrap; column-gap: 12px; }
.rp-chart { position: relative; min-width: 0; }
.rp-legend { display: inline-flex; align-items: center; gap: 10px; color: var(--mute); font-size: var(--fs-caption); }
.lg-line { width: 30px; height: 0; border-top: 2px solid var(--acc); border-radius: 1px; position: relative; }
.lg-line::after { content: ""; position: absolute; left: 11px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--acc); }
.rp-note { color: var(--mute); font-size: var(--fs-caption); margin: 0; }

/* Status now */
.rp-rows { list-style: none; margin: 0; padding: 0; display: grid; }
.rp-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 40px; align-items: center; gap: 12px; min-height: 34px; border-top: 1px solid var(--line); }
.rp-rows .rp-row:first-child { border-top: 0; }
.rp-row.is-zero { color: var(--dim); }
.rp-label { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-body); color: var(--text); }
.rp-row.is-zero .rp-label { color: var(--mute); }
.rp-track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.rp-track i { display: block; height: 100%; min-width: 0; border-radius: 4px; background: var(--c); }
.rp-n { text-align: right; font-family: var(--mono); font-size: var(--fs-body); font-weight: 600; }

/* Overdue */
.rp-late-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.rp-late { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 52px; padding: 6px 4px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; border-radius: var(--r-sm); }
.rp-late-list li:first-child .rp-late { border-top: 0; }
.rp-late:hover { background: var(--panel2); }
.rp-late-text { flex: 1 1 120px; min-width: 0; display: grid; gap: 2px; }
.rp-late-text b { font-size: var(--fs-body); font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-late-text span { color: var(--mute); font-size: var(--fs-caption); }
.rp-due { color: var(--bad); font-size: var(--fs-caption); font-family: var(--mono); white-space: nowrap; }
.rp-late > svg { color: var(--dim); flex: none; }
.rp-none { color: var(--mute); margin: 0; padding: 4px 0; }
.rp-status .stack, .rp-card .stack { margin-bottom: 4px; }

/* Chart tables */
.rp-table summary { cursor: pointer; color: var(--acc); font-size: var(--fs-caption); font-weight: 600; width: max-content; padding: 2px 0; }
.rp-table table { table-layout: fixed; overflow-wrap: anywhere; width: 100%; border-collapse: collapse; margin-top: 6px; font-size: var(--fs-caption); font-family: var(--mono); }
.rp-table th, .rp-table td { text-align: left; padding: 5px 8px; border-top: 1px solid var(--line); }
.rp-table thead th { color: var(--mute); font-weight: 600; border-top: 0; }

/* SVG charts */
.chart { display: block; width: 100%; max-width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.ch-grid { stroke: var(--track); stroke-width: 1; }
.ch-grid-v { stroke-dasharray: 2 4; }
.ch-ylab, .ch-xlab { fill: var(--dim); font-size: var(--fs-caption); font-family: var(--mono); }
.ch-val { fill: var(--text); font-size: var(--fs-caption); font-weight: 600; font-family: var(--mono); paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.ch-line { fill: none; stroke: var(--acc); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.ch-area { fill: var(--acc); opacity: .1; stroke: none; }
.ch-dot { fill: var(--acc); stroke: var(--panel); stroke-width: 2; transition: r .1s; }
.ch-gap { fill: var(--panel2); }
.ch-gaplab { fill: var(--dim); font-size: var(--fs-caption); font-style: italic; }
.ch-barfill { fill: var(--bar0); }
.ch-barfill.is-now { fill: var(--acc); }
.ch-zero { stroke: var(--line2); stroke-width: 2; }
.ch-band { fill: transparent; }
.ch-cross { stroke: var(--mute); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.ch-pt, .ch-bar { outline: none; cursor: default; }
.ch-pt:hover .ch-band, .ch-pt:focus .ch-band, .ch-bar:hover .ch-band, .ch-bar:focus .ch-band { fill: var(--panel3); opacity: .6; }
.ch-pt:hover .ch-cross, .ch-pt:focus .ch-cross { opacity: 1; }
.ch-pt:hover .ch-dot, .ch-pt:focus .ch-dot { r: 6; }
.ch-pt:focus-visible .ch-band, .ch-bar:focus-visible .ch-band { stroke: var(--acc); stroke-width: 2; }

.chart-tip { position: fixed; z-index: 60; pointer-events: none; max-width: 260px; padding: 8px 12px; border-radius: var(--r); background: var(--text); color: var(--panel); font-size: var(--fs-caption); line-height: 1.4; white-space: pre-line; border: 1px solid var(--line2); }
.chart-tip b { font-size: var(--fs-caption); display: block; }
.chart-tip[hidden] { display: none; }

.rp-state { margin: 20px 24px; }

@media (max-width: 1100px) {
  .rp-progress, .rp-weeks, .rp-status, .rp-overdue { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .reports { padding: 14px 12px 22px; }
  .rp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp-row { grid-template-columns: minmax(0, 124px) minmax(24px, 1fr) 34px; gap: 10px; }
  .rp-label { min-width: 0; overflow: hidden; }
}
/* Docked: one column, the progress chart first. */
.rp-docked.reports { padding: 12px 12px 18px; gap: 12px; }
.rp-docked .rp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rp-docked .rp-grid { grid-template-columns: minmax(0, 1fr); }
.rp-docked .rp-progress, .rp-docked .rp-weeks, .rp-docked .rp-status, .rp-docked .rp-overdue { grid-column: 1 / -1; }
.rp-docked .rp-row { grid-template-columns: 116px minmax(0, 1fr) 30px; gap: 8px; }
.rp-docked .rp-late-text b { white-space: normal; }
.rp-docked .rp-due { white-space: normal; text-align: right; max-width: 6.5em; }
