/* Designed for a non-technical 70+ user: large type, high contrast,
   one obvious action per step, visible focus everywhere. */

:root {
  --ink: #1a1a1a;
  --muted: #504d47;
  --paper: #fafaf7;
  --card: #ffffff;
  --line: #c8c4bc;
  --action: #1e40af;
  --action-dark: #172f85;
  --focus: #b45309;
  --pass-ink: #14652f;
  --pass-bg: #e7f4ec;
  --fail-ink: #8f1d14;
  --fail-bg: #fdeceb;
  --warn-ink: #6b4302;
  --warn-bg: #fdf3e0;
  --warn-line: #b45309;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win: author display rules (e.g. .preview's
   display: flex) otherwise override the UA's [hidden] { display: none }. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1.25rem;
  line-height: 1.6;
}

main {
  max-width: 45rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

h1 { font-size: 2rem; margin: 0 0 0.25rem; }
.lede { margin: 0 0 0.75rem; color: var(--muted); }

.disclosure { margin: 0 0 1.5rem; font-size: 1rem; color: var(--muted); }

h2 { font-size: 1.4rem; margin: 0 0 1rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---- mode toggle ---- */

.mode-toggle {
  display: flex;
  border: 2px solid var(--action);
  border-radius: 0.6rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.mode-button {
  flex: 1;
  min-height: 3rem;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  background: #fff;
  color: var(--action);
  border: 0;
  cursor: pointer;
}

.mode-button[aria-pressed="true"] {
  background: var(--action);
  color: #fff;
}

/* ---- steps ---- */

fieldset { border: 0; margin: 0; padding: 0; }

.step {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 1.15rem;
}

.step-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---- image picker ---- */

.file-button {
  display: block;
  border: 3px dashed var(--action);
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--action);
  font-weight: 700;
  cursor: pointer;
}

.file-button:hover { background: #eef2ff; }

.file-button:has(:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.preview img {
  max-width: 9rem;
  max-height: 9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

/* ---- fields ---- */

.field { margin-bottom: 1.4rem; }
.field:last-child { margin-bottom: 0; }

label { display: block; font-weight: 700; }

.hint {
  margin: 0.1rem 0 0.4rem;
  font-size: 1rem;
  color: var(--muted);
}

input, textarea {
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--muted);
  border-radius: 0.5rem;
}

input[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--fail-ink);
  background: var(--fail-bg);
}

.field-error {
  margin: 0.4rem 0 0;
  color: var(--fail-ink);
  font-weight: 700;
}

/* ---- buttons ---- */

.primary-button {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  background: var(--action);
  border: 0;
  border-radius: 0.6rem;
  cursor: pointer;
}

.primary-button:hover { background: var(--action-dark); }
.primary-button[disabled] { opacity: 0.7; cursor: wait; }

.secondary-button {
  margin-top: 0.6rem;
  min-height: 2.8rem;
  padding: 0.4rem 1rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--action);
  background: #fff;
  border: 2px solid var(--action);
  border-radius: 0.5rem;
  cursor: pointer;
}

.secondary-button:hover { background: #eef2ff; }

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font: inherit;
  font-size: 1.05rem;
  color: var(--action);
  background: none;
  border: 0;
  padding: 0.25rem;
  text-decoration: underline;
  cursor: pointer;
}

/* ---- loading ---- */

.status { min-height: 1.8rem; margin: 0.8rem 0 0; color: var(--muted); }

.spinner {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  margin-right: 0.4rem;
  vertical-align: -0.15rem;
  border: 3px solid var(--line);
  border-top-color: var(--action);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

/* ---- error banner ---- */

#error-banner {
  background: var(--fail-bg);
  color: var(--fail-ink);
  border: 2px solid var(--fail-ink);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* ---- results ---- */

#verdict {
  border-radius: 0.75rem;
  padding: 1.5rem;
  font-size: 1.6rem;
  font-weight: 800;
  border: 3px solid;
}

#verdict.approved {
  color: var(--pass-ink);
  background: var(--pass-bg);
  border-color: var(--pass-ink);
}

#verdict.needs-review {
  color: var(--warn-ink);
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.timing { color: var(--muted); font-size: 1rem; margin: 0.6rem 0 1.5rem; }

/* Low-legibility advisory: same amber family as NEEDS REVIEW (icon + words,
   never color alone); --warn-ink on --warn-bg passes WCAG at 8.6:1. */
.quality-banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 2px solid var(--warn-line);
  border-radius: 0.75rem;
  padding: 0.9rem 1.25rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.result-rows { list-style: none; margin: 0 0 2rem; padding: 0; }

.result-rows li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.row-top .name { font-weight: 700; }

.chip {
  flex-shrink: 0;
  font-weight: 800;
  border-radius: 2rem;
  padding: 0.15rem 0.9rem;
  border: 2px solid;
}

.chip.pass { color: var(--pass-ink); background: var(--pass-bg); border-color: var(--pass-ink); }
.chip.fail { color: var(--fail-ink); background: var(--fail-bg); border-color: var(--fail-ink); }
.chip.warn { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-line); }

.mismatch {
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.mismatch dt { font-size: 1rem; color: var(--muted); }
.mismatch dd { margin: 0 0 0.5rem; font-weight: 600; }

.detail { font-size: 0.95rem; color: var(--muted); margin: 0.25rem 0 0; }

/* Evidence-on-demand for matched rows (mirrors .item-details in batch). */
.row-details summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  margin-top: 0.25rem;
  color: var(--action);
  font-weight: 700;
  cursor: pointer;
}

.row-details .detail { margin: 0.25rem 0 0.4rem; }

/* ---- batch cards ---- */

.batch-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-head img {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
}

.card-head .fname {
  flex: 1;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.card-grid .field { margin-bottom: 0; }
.card-grid label { font-size: 1rem; }
.card-grid .hint { font-size: 0.9rem; }

.card-grid input,
.card-grid textarea {
  min-height: 2.75rem;
  font-size: 1.05rem;
}

.card-grid .span2 { grid-column: 1 / -1; }

@media (max-width: 40rem) {
  .card-grid { grid-template-columns: 1fr; }
}

/* ---- batch summary tiles ---- */

.summary-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 40rem) {
  .summary-tiles { grid-template-columns: repeat(2, 1fr); }
}

.tile {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.9rem 0.5rem;
  text-align: center;
}

.tile .num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
}

.tile .lbl { font-size: 1rem; font-weight: 700; }

.tile.pass { border-color: var(--pass-ink); }
.tile.pass .lbl { color: var(--pass-ink); }
.tile.warn { border-color: var(--warn-line); }
.tile.warn .lbl { color: var(--warn-ink); }
.tile.fail { border-color: var(--fail-ink); }
.tile.fail .lbl { color: var(--fail-ink); }

/* ---- batch result rows ---- */

.row-sub { color: var(--muted); font-size: 1rem; }

.item-details summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  margin-top: 0.25rem;
  color: var(--action);
  font-weight: 700;
  cursor: pointer;
}

.item-details .result-rows { margin: 0.5rem 0 0; }

.error-text {
  margin: 0.5rem 0 0;
  color: var(--fail-ink);
  font-weight: 600;
}
