/* analysis screen styles (redesign) — builds on assets/css/testflow.css tokens */

/* Outcome colours differ in lightness as well as hue, per theme */
:root,
[data-bs-theme=light] {
  --tfa-ok: #0E7C7B;
  --tfa-fail: #F3A59D;
  --tfa-partial: #F2B54B;
  --tfa-skip: #D0D5DD;
  --tfa-band-awful: #F3D3CF;
  --tfa-band-poor: #F8E1CF;
  --tfa-band-ok: #F8EBC4;
  --tfa-band-good: #CDE8E6;
  --tfa-band-excellent: #9FD3CF;
}

[data-bs-theme=dark] {
  --tfa-ok: #3CC2B6;
  --tfa-fail: #8A2F27;
  --tfa-partial: #B07A1E;
  --tfa-skip: #3A4456;
  --tfa-band-awful: #4A1F1B;
  --tfa-band-poor: #4A3020;
  --tfa-band-ok: #4A3E1C;
  --tfa-band-good: #1D4744;
  --tfa-band-excellent: #26635E;
}

.tfa-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.tfa-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 4px;
  list-style: none;
  border-radius: 0;
  background: var(--tf-chip);
}

.tfa-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 0;
  color: var(--tf-text);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.tfa-tabs a:hover { color: var(--tf-ink); }

.tfa-tabs a[aria-current="page"] {
  background: var(--tf-surface);
  color: var(--tf-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.tfa-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.tfa-kpi {
  padding: 16px 18px;
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: 0;
}

.tfa-kpi-label {
  font-size: 13px;
  color: var(--tf-muted);
}

.tfa-kpi-value {
  margin-top: 4px;
  font-family: var(--tf-font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--tf-ink);
  font-variant-numeric: tabular-nums;
}

.tfa-kpi-note {
  font-size: 13px;
  color: var(--tf-text);
}

.tfa-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.tfa-wide { flex: 999 1 560px; min-width: 0; }
.tfa-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

.tfa-table {
  width: 100%;
  min-width: 620px;
  margin: 0;
  border-collapse: collapse;
}

.tfa-table-wide { min-width: 860px; }

.tfa-table th {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  color: var(--tf-muted);
  background: var(--tf-surface-2);
  border-bottom: 1px solid var(--tf-divider);
  white-space: nowrap;
}

.tfa-table td {
  padding: 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--tf-divider);
  color: var(--tf-ink);
}

.tfa-table th:first-child,
.tfa-table td:first-child { padding-left: 18px; }

.tfa-table th:last-child,
.tfa-table td:last-child { padding-right: 18px; }

.tfa-table tr:last-child td { border-bottom: 0; }

.tfa-num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.tfa-task-name {
  display: block;
  font-weight: 600;
  max-width: 48ch;
}

.tfa-sub {
  display: block;
  font-size: 12px;
  color: var(--tf-muted);
}

.tfa-stack {
  display: flex;
  gap: 2px;
  height: 12px;
  border-radius: 0;
  overflow: hidden;
  background: var(--tf-divider);
}

.tfa-stack > span { display: block; height: 100%; }
.tfa-ok { background: var(--tfa-ok); }
.tfa-fail { background: var(--tfa-fail); }
.tfa-partial { background: var(--tfa-partial); }
.tfa-skip { background: var(--tfa-skip); }

.tfa-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--tf-text);
}

.tfa-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tfa-swatch {
  width: 10px;
  height: 10px;
  border-radius: 0;
}

.tfa-score {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.tfa-score-value {
  font-family: var(--tf-font-display);
  font-size: 44px;
  font-weight: 700;
  color: var(--tf-ink);
  font-variant-numeric: tabular-nums;
}

.tfa-band {
  position: relative;
  height: 40px;
}

.tfa-band-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  height: 12px;
  display: flex;
  gap: 2px;
  border-radius: 0;
  overflow: hidden;
}

.tfa-band-marker {
  position: absolute;
  top: 4px;
  width: 3px;
  height: 32px;
  margin-left: -1px;
  border-radius: 0;
  background: var(--tf-ink);
}

.tfa-band-labels {
  display: grid;
  grid-template-columns: 38fr 13fr 20fr 14fr 15fr;
  font-size: 12px;
  color: var(--tf-text);
}

.tfa-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
}

.tfa-dl dt { font-weight: 500; color: var(--tf-text); }
.tfa-dl dd { margin: 0; text-align: right; font-weight: 600; color: var(--tf-ink); font-variant-numeric: tabular-nums; }

.tfa-bars {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tfa-bar-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 4px;
}

.tfa-bar-row span:last-child {
  font-weight: 600;
  color: var(--tf-ink);
  font-variant-numeric: tabular-nums;
}

.tfa-summary {
  color: var(--tf-text);
  line-height: 1.6;
}

.tfa-summary p:last-child { margin-bottom: 0; }

.tfa-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--tf-muted);
}

.tfa-issue {
  padding: 12px 18px;
  border-bottom: 1px solid var(--tf-divider);
}

.tfa-issue:last-child { border-bottom: 0; }

.tfa-chart { min-height: 300px; }

.tfa-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.tfa-section-title {
  margin: 8px 0 14px;
  font-family: var(--tf-font);
  font-size: 17px;
  font-weight: 600;
  color: var(--tf-ink);
}

/* Findings and decisions */
.tff-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tff-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid var(--tf-divider);
}

.tff-item:last-child { border-bottom: 0; }

.tff-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tff-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.tff-task {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--tf-muted);
}

.tff-observation {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--tf-ink);
}

.tff-decision {
  padding: 12px 14px;
  border-left: 3px solid var(--tf-accent);
  border-radius: 0;
  background: var(--tf-surface-2);
  color: var(--tf-text);
}

.tff-label {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tf-muted);
}

.tff-drafts { border-style: dashed; }
.tff-draft .tff-decision { border-left-color: var(--tf-border-strong); }

.tff-draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tff-flagged {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tff-flagged li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--tf-divider);
}

.tff-flagged li:last-child { border-bottom: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 767.98px) {
  /* Views scroll sideways in one row; the export button sits under them */
  .tfa-subnav { margin-bottom: 16px; }
  .tfa-subnav > nav { width: 100%; }
  .tfa-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tfa-tabs a { white-space: nowrap; }

  .tfa-kpis { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .tfa-kpi { padding: 12px 14px; }
  .tfa-kpi-value { font-size: 22px; }

  /* Task tables: one block per task, the bar full width, figures underneath */
  .tfa-table-cards,
  .tfa-table-wide { min-width: 0; }
  .tfa-table-cards thead { display: none; }
  .tfa-table-cards,
  .tfa-table-cards tbody { display: block; }
  .tfa-table-cards tbody tr {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--tf-divider);
  }
  .tfa-table-cards td { display: block; padding: 0 !important; border: 0 !important; text-align: left !important; }
  .tfa-table-cards td:nth-child(-n+2) { grid-column: 1 / -1; }
  .tfa-table-cards td.tfa-num { font-size: 13px; color: var(--tf-muted); }
  .tfa-table-cards td[data-label]::before { content: attr(data-label) " "; font-weight: 400; }
  .tfa-table-cards td.tfa-num { color: var(--tf-ink); font-weight: 600; }
  .tfa-table-cards td.tfa-num::before { color: var(--tf-muted); }
}
