/* Payment Tracking — Insights.
 *
 * Reuses the Reports screen's KPI cards and the Dashboard's scope bar, so a
 * reader arriving from either recognises the furniture. What is new here is
 * the section card, the four-step cash-cycle strip, the target bar and the
 * "needs data" note — the one place this screen says plainly that a number
 * cannot be measured yet rather than printing a zero.
 *
 * The report accents are re-declared on this view because pts.css scopes them
 * to #view-pts-reports; same hexes, so a paid figure is the same green here.
 */

#view-pts-insights {
  --rep-billed: var(--text);
  --rep-paid: #1baf7a;
  --rep-open: #eb6834;
  --rep-expected: #2a78d6;
  --rep-negative: #c0392b;
}
[data-theme="dark"] #view-pts-insights {
  --rep-paid: #199e70;
  --rep-open: #d95926;
  --rep-expected: #3987e5;
  --rep-negative: #e66767;
}

/* ---------- jump links ---------- */
.ptsi-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: -6px 0 16px;
}
.ptsi-jump a {
  font-size: calc(12px * var(--ui-font-scale, 1));
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface);
}
.ptsi-jump a:hover { color: var(--text); border-color: var(--text-muted); }

/* ---------- section card ---------- */
.ptsi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px 20px;
  margin-bottom: 18px;
  scroll-margin-top: 16px;
}
.ptsi-card:empty { display: none; }
.ptsi-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 14px;
}
.ptsi-head h3 { margin: 0 0 4px; font-size: calc(16px * var(--ui-font-scale, 1)); }
.ptsi-plain { margin: 0; font-size: calc(13px * var(--ui-font-scale, 1)); color: var(--text-muted); max-width: 72ch; line-height: 1.45; }
.ptsi-muted { font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--text-muted); margin: 6px 0; }
.ptsi-foot { font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--text-muted); margin: 12px 0 0; line-height: 1.5; }
.ptsi-error { color: var(--error); font-size: calc(13px * var(--ui-font-scale, 1)); }
.ptsi-sub { font-size: calc(13px * var(--ui-font-scale, 1)); margin: 18px 0 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.ptsi-sub .ptsi-muted { margin: 0; font-weight: 400; }
.ptsi-example {
  font-size: calc(12.5px * var(--ui-font-scale, 1));
  line-height: 1.5;
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* "Needs data" — said in words, never shown as a zero. */
.ptsi-needs {
  font-size: calc(12.5px * var(--ui-font-scale, 1));
  line-height: 1.45;
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px dashed var(--warning);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
}

/* ---------- cash-cycle strip ---------- */
.ptsi-stages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.ptsi-stage {
  position: relative;
  padding: 14px 14px 12px 44px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--rep-expected);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.ptsi-stage.is-missing { border-top-color: var(--warning); }
.ptsi-stage.is-ratio { border-top-color: var(--rep-paid); }
.ptsi-stage h4 { margin: 0 0 4px; font-size: calc(13px * var(--ui-font-scale, 1)); }
.ptsi-stage .ptsi-plain { font-size: calc(12px * var(--ui-font-scale, 1)); }
.ptsi-stage-no {
  position: absolute;
  left: 12px;
  top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: calc(12px * var(--ui-font-scale, 1));
  font-weight: 700;
  display: grid;
  place-items: center;
}
.ptsi-big {
  font-size: calc(22px * var(--ui-font-scale, 1));
  font-weight: 700;
  margin: 10px 0 2px;
  font-variant-numeric: tabular-nums;
}
.ptsi-big.is-proxy { color: var(--text-muted); }

/* ---------- target ---------- */
.ptsi-target { margin-bottom: 14px; }
.ptsi-target-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: calc(14px * var(--ui-font-scale, 1)); }
.ptsi-target-row strong { font-size: calc(20px * var(--ui-font-scale, 1)); font-variant-numeric: tabular-nums; }
.ptsi-bar {
  height: 12px;
  margin: 8px 0 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.ptsi-bar i { display: block; height: 100%; background: var(--rep-paid); border-radius: 999px; }
.ptsi-chip {
  font-size: calc(11px * var(--ui-font-scale, 1));
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.ptsi-chip.is-good { background: var(--success); color: #fff; }
.ptsi-chip.is-bad { background: var(--warning); color: #1d1600; }

/* ---------- layout helpers ---------- */
.ptsi-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.ptsi-chart { min-height: 220px; margin-top: 12px; }
.ptsi-spacer { flex: 1 1 auto; }

/* ---------- tables ---------- */
.ptsi-table-wrap { overflow-x: auto; max-height: 520px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ptsi-table-wrap.ptsi-tall { max-height: 360px; }
.ptsi-table { width: 100%; border-collapse: collapse; font-size: calc(12.5px * var(--ui-font-scale, 1)); }
.ptsi-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-size: calc(11px * var(--ui-font-scale, 1));
  font-weight: 600;
  color: var(--text-muted);
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ptsi-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ptsi-table tr:last-child td { border-bottom: 0; }
.ptsi-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ptsi-table td.is-negative { color: var(--rep-negative); }
.ptsi-table input.pts-select { width: 110px; padding: 4px 6px; }

/* ---------- rules disclosure ---------- */
.ptsi-rules { margin: 12px 0 0; font-size: calc(12.5px * var(--ui-font-scale, 1)); }
.ptsi-rules summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.ptsi-rules ul { margin: 8px 0; padding-left: 18px; line-height: 1.5; }

/* ---------- queue ---------- */
.ptsi-queue-bar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; }
.ptsi-queue-bar input[type="text"] { min-width: 180px; }

/* ---------- settings ---------- */
.ptsi-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
}
.ptsi-upload {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.ptsi-upload h4 { margin: 0 0 6px; font-size: calc(13px * var(--ui-font-scale, 1)); }
