:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --ok: #15803d;
  --fail: #b91c1c;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand small {
  display: block;
  color: var(--muted);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
}

.nav a.active {
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 600;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

h1,
h2 {
  margin: 0 0 8px;
}

.lead {
  color: var(--muted);
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.form {
  display: grid;
  gap: 12px;
  max-width: 420px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input[type='text'],
input[type='file'],
input:not([type]) {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

button {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-top: 12px;
}

.alert.ok {
  background: #dcfce7;
  color: var(--ok);
}

.alert.err {
  background: #fee2e2;
  color: var(--fail);
}

.grid.matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #eef2ff;
}

.card-body {
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox-row input {
  width: auto;
}

.gallery-groups {
  display: grid;
  gap: 24px;
  margin-top: 16px;
}

.gallery-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.btn-link {
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 600;
  text-align: left;
}

.btn-danger {
  background: #fee2e2;
  color: var(--fail);
  padding: 8px 10px;
  font-size: 13px;
}

.matrix-card form {
  margin: 0;
}

.matrix-summary-grid {
  margin-top: 16px;
}

.matrix-summary-card .card-body {
  gap: 8px;
}

.btn-secondary {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 600;
}

.breadcrumb {
  margin: 0 0 12px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.attempt-list {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.attempt-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.attempt-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.attempt-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
}

.pill.ok {
  background: #dcfce7;
  color: var(--ok);
}

.pill.fail {
  background: #fee2e2;
  color: var(--fail);
}

.match {
  font-weight: 700;
}

.attempt-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.attempt-reason-col {
  flex: 1;
  min-width: 0;
}

/* Tentativas: miniaturas a 30% da largura da coluna (só exibição) */
.attempt-card .compare {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  gap: 16px;
  justify-content: flex-end;
}

.attempt-card .compare figure {
  margin: 0;
  min-width: 0;
  display: grid;
  gap: 8px;
  justify-items: start;
  align-content: start;
  width: 150px;
}

.attempt-card .compare figcaption {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.attempt-card .attempt-thumb {
  width: 100%;
  min-width: 0;
}

.attempt-card .attempt-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #eef2ff;
  filter: grayscale(100%);
}

.attempt-card .attempt-thumb.placeholder {
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  border: 1px dashed var(--border);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
}

.reason {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
}

@media (max-width: 720px) {
  .attempt-body {
    flex-direction: column;
  }

  .attempt-card .compare {
    width: 100%;
    justify-content: flex-start;
  }
}
