/**
 * Grant Report admin tab — scoped styles. Reuses the dashboard base classes;
 * only adds what's specific to this reporting surface. Brand red #bd2727.
 *
 * @package SoberAF\ProgramReport
 */

.saf-progreport__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin: 12px 0 8px;
}
.saf-progreport__control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  font-weight: 600;
}
.saf-progreport__control select {
  min-width: 220px;
  padding: 6px 8px;
}

.saf-progreport__status {
  margin: 8px 0;
  font-style: italic;
  color: #555;
}
.saf-progreport__status.is-error {
  color: #bd2727;
  font-style: normal;
  font-weight: 600;
}

.saf-progreport__metricpick {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid #e0d9d9;
  border-radius: 8px;
  background: #faf7f7;
}
.saf-progreport__metricpick legend {
  font-weight: 700;
  padding: 0 6px;
}
.saf-progreport__metricpick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 16px;
  margin-bottom: 10px;
}
.saf-progreport__metricpick-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 400;
  cursor: pointer;
}

.saf-progreport__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 14px 0;
}
.saf-progreport__stat {
  flex: 1 1 200px;
  min-width: 180px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e6dede;
  border-left: 4px solid #bd2727;
}
.saf-progreport__stat-num {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  color: #bd2727;
}
.saf-progreport__stat-lbl {
  font-weight: 600;
  margin-top: 2px;
}
.saf-progreport__stat-sub {
  font-size: 0.82rem;
  color: #666;
  margin-top: 4px;
}

.saf-progreport__table th[scope="row"] {
  text-align: left;
  font-weight: 600;
}
.saf-progreport__row--people {
  background: #fbeded;
  font-weight: 700;
}
.saf-progreport__na {
  color: #aaa;
  text-align: center;
}

.saf-progreport__notes {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff8e6;
  border: 1px solid #f0e2b8;
}
.saf-progreport__notes-title {
  font-weight: 700;
  margin: 0 0 4px;
}
.saf-progreport__notes-list {
  margin: 0;
  padding-left: 18px;
}
.saf-progreport__notes-list li {
  margin: 2px 0;
}

@media (max-width: 640px) {
  .saf-progreport__controls {
    flex-direction: column;
    align-items: stretch;
  }
  .saf-progreport__control,
  .saf-progreport__control select {
    min-width: 0;
    width: 100%;
  }
}

/* ---- Grant Objectives (session 56, Phase 4) ---- */
.saf-progreport__objectives {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--saf-border, #e2ddd3);
}
.saf-progreport__objectives-heading {
  margin: 0 0 4px;
}
.saf-progreport__obj-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.saf-progreport__obj-row {
  padding: 10px 12px;
  border: 1px solid var(--saf-border, #e2ddd3);
  border-radius: 8px;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.saf-progreport__obj-main {
  flex: 1 1 260px;
  min-width: 0;
}
.saf-progreport__obj-text {
  font-weight: 600;
}
.saf-progreport__obj-note {
  font-size: 0.85em;
  color: #6b6459;
  margin-top: 2px;
  white-space: pre-wrap;
}
.saf-progreport__obj-bar {
  flex: 1 1 160px;
  height: 10px;
  border-radius: 999px;
  background: var(--saf-border, #e9e4da);
  overflow: hidden;
}
.saf-progreport__obj-bar-fill {
  height: 100%;
  background: var(--saf-brick-red, #be2727);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.saf-progreport__obj-bar-fill.is-full {
  background: var(--saf-emerald, #2e7d5b);
}
.saf-progreport__obj-barlbl,
.saf-progreport__obj-narrative {
  flex: 0 0 auto;
  font-size: 0.85em;
  color: #6b6459;
  white-space: nowrap;
}
.saf-progreport__obj-remove {
  flex: 0 0 auto;
  margin-left: auto;
}
.saf-progreport__obj-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--saf-border, #e2ddd3);
  border-radius: 8px;
}
.saf-progreport__obj-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 160px;
}
.saf-progreport__obj-field--wide {
  flex: 1 1 100%;
}
.saf-progreport__obj-field > span {
  font-size: 0.85em;
  font-weight: 600;
}
@media (max-width: 640px) {
  .saf-progreport__obj-row,
  .saf-progreport__obj-form {
    flex-direction: column;
    align-items: stretch;
  }
  .saf-progreport__obj-remove {
    margin-left: 0;
  }
}

/* ---- Milestones timeline (session 56, Phase 5) ---- */
.saf-progreport__milestones {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--saf-border, #e2ddd3);
}
.saf-progreport__milestones-heading {
  margin: 0 0 4px;
}
.saf-progreport__timeline {
  list-style: none;
  margin: 12px 0;
  padding: 0 0 0 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.saf-progreport__ms-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--saf-border, #e2ddd3);
  border-left: 4px solid var(--saf-brick-red, #be2727);
  border-radius: 8px;
  background: #fff;
}
.saf-progreport__ms-thumb {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--saf-border, #eee);
}
.saf-progreport__ms-body {
  flex: 1 1 auto;
  min-width: 0;
}
.saf-progreport__ms-title {
  font-weight: 700;
}
.saf-progreport__ms-date {
  display: block;
  font-size: 0.85em;
  color: #6b6459;
  margin: 2px 0;
}
.saf-progreport__ms-note {
  margin-top: 4px;
  white-space: pre-wrap;
}
.saf-progreport__ms-remove {
  flex: 0 0 auto;
  margin-left: auto;
}
.saf-progreport__ms-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--saf-border, #e2ddd3);
  border-radius: 8px;
}
.saf-progreport__ms-picker {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}
.saf-progreport__ms-preview {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--saf-border, #e2ddd3);
}
.saf-progreport__ms-picked {
  font-size: 0.9em;
  color: #6b6459;
}
.saf-progreport__ms-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 160px;
}
.saf-progreport__ms-field--wide {
  flex: 1 1 100%;
}
.saf-progreport__ms-field > span {
  font-size: 0.85em;
  font-weight: 600;
}
.saf-progreport__ms-grid {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--saf-border, #e2ddd3);
  border-radius: 8px;
}
.saf-progreport__ms-gridimg {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.saf-progreport__ms-gridimg:hover,
.saf-progreport__ms-gridimg:focus-visible {
  border-color: var(--saf-brick-red, #be2727);
}
.saf-progreport__ms-gridimg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
@media (max-width: 640px) {
  .saf-progreport__ms-row,
  .saf-progreport__ms-form {
    flex-direction: column;
    align-items: stretch;
  }
  .saf-progreport__ms-remove {
    margin-left: 0;
  }
}

/* Peer Training Outcomes (Polaris) — roster-wide, not program-scoped. */
.saf-progreport__polaris {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--saf-border, #e2ddd3);
}
.saf-progreport__polaris-heading {
  margin: 0 0 4px;
}
/* Same flex row as .saf-progreport__summary; the tiles inside reuse
   .saf-progreport__stat so the two blocks stay visually identical. */
.saf-progreport__polaris-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 14px 0;
}
.saf-progreport__polaris-note {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff8e6;
  border: 1px solid #f0e2b8;
  font-size: 0.9rem;
}

/* s113: upstream data-quality gaps. Deliberately understated -- these are
   context for reading a figure, not an error state, and a red alarm on a
   permanent upstream condition trains the reader to ignore it. */
.saf-progreport__gaps-wrap {
	margin-top: 1.25rem;
	padding: 0.85rem 1rem;
	border-left: 3px solid #bd2727;
	background: #faf7f4;
	border-radius: 4px;
}
.saf-progreport__gaps-heading {
	margin: 0 0 0.5rem;
	font-size: 0.95rem;
}
.saf-progreport__gaps {
	margin: 0;
	padding-left: 1.1rem;
	font-size: 0.88rem;
	line-height: 1.5;
}
.saf-progreport__gap + .saf-progreport__gap {
	margin-top: 0.4rem;
}
.saf-progreport__gap-count {
	display: inline-block;
	min-width: 2.2em;
	margin-right: 0.4em;
	padding: 0 0.4em;
	border-radius: 3px;
	background: #bd2727;
	color: #fff;
	font-weight: 700;
	text-align: center;
}

/* s113: the funding tables are read COLUMN-wise (compare people across funds),
   so the numeric columns must align with each other. The shared table base
   right-aligns the LAST cell, which left three numbers ragged against one. */
.saf-dash-table.saf-progreport__polaris-table td,
.saf-dash-table.saf-progreport__polaris-table td:last-child {
	text-align: left;
	font-variant-numeric: tabular-nums;
}

/* s132: the per-seat table carries five columns, one of them a long funding-year
   label ("[2026] SIGNAL - SSPA 1/2/4/7 | 2025-2026"). The base dash table sets
   `white-space: nowrap` on the first data columns, which pushed this table to
   641px inside a 325px wrapper at 375 -- two columns off-screen, where the
   sibling fund/year tables sit at 347/422. All three live in
   `.saf-dash-table-scroll` (overflow-x: auto) so nothing is unreachable, but a
   number the reader cannot see is a number they will not check.
   Let the year label wrap so the numeric columns come back into view. Scoped to
   this table only -- the fund/year tables above are unchanged. */
@media (max-width: 640px) {
	.saf-dash-table.saf-progreport__polaris-table[data-saf-progreport-funding-seat] td,
	.saf-dash-table.saf-progreport__polaris-table[data-saf-progreport-funding-seat] th {
		white-space: normal;
	}
	/* The year label is the widest cell by far and the LEAST load-bearing of the
	   five: the seat id already identifies the row, and the two numeric columns
	   are the point of the table. Cap it so "Seats used / total" and
	   "Utilisation" fit on screen instead of sitting past the scroll edge. The
	   full label stays reachable by scrolling the wrapper. */
	.saf-dash-table.saf-progreport__polaris-table[data-saf-progreport-funding-seat] td:nth-child(2) {
		max-width: 7.5em;
		font-size: 0.92em;
		line-height: 1.3;
	}
	.saf-dash-table.saf-progreport__polaris-table[data-saf-progreport-funding-seat] th:first-child,
	.saf-dash-table.saf-progreport__polaris-table[data-saf-progreport-funding-seat] td:first-child {
		padding-right: 6px;
	}
}
