:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffdf8;
  --panel-border: #d9d1c4;
  --text: #1f1d18;
  --muted: #6c665c;
  --accent: #0f5f57;
  --accent-soft: #dceee9;
  --danger: #a53a2d;
  --danger-soft: #f6e1dc;
  --success: #1e6b3f;
  --success-soft: #dfefdf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: linear-gradient(180deg, #f9f8f3 0%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.button-secondary {
  background: transparent;
  color: var(--accent);
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
}

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--panel-border);
  background: rgba(255, 253, 248, 0.96);
}

.header-row,
.page-header,
.section-row,
.actions-row,
.inline-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.header-row,
.page-header {
  padding: 1.25rem 0;
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.subtitle,
.muted,
.fact-meta {
  color: var(--muted);
}

.nav-list {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-shell {
  padding: 2rem 0 3rem;
}

.panel,
.empty-state,
.flash {
  border: 1px solid var(--panel-border);
  border-radius: 0.85rem;
  background: var(--panel);
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(72, 59, 35, 0.05);
}

.narrow-panel {
  max-width: 760px;
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash-success {
  border-color: #b8d5b8;
  background: var(--success-soft);
}

.flash-error {
  border-color: #dfb9b2;
  background: var(--danger-soft);
}

.filter-form,
.stack-form,
.field-grid,
.detail-grid,
.facts-layout,
.score-grid,
.fact-stack,
.checkbox-grid,
.tag-badges {
  display: grid;
  gap: 1rem;
}

.filter-form {
  grid-template-columns: auto minmax(180px, 240px) auto;
  align-items: end;
}

.filter-form-wide {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}

.field-grid,
.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-grid,
.facts-layout {
  margin-bottom: 1rem;
}

.field-group {
  display: grid;
  gap: 0.4rem;
}

.checkbox-fieldset {
  border: 1px solid #e5ddd1;
  border-radius: 0.7rem;
  padding: 0.9rem;
}

.checkbox-fieldset legend {
  padding: 0 0.35rem;
  font-weight: 700;
}

.checkbox-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-option {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.checkbox-option input {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #bbb2a4;
  border-radius: 0.5rem;
  background: #fff;
}

textarea {
  resize: vertical;
}

.job-table {
  width: 100%;
  border-collapse: collapse;
}

.job-table th,
.job-table td {
  padding: 0.8rem 0.65rem;
  border-bottom: 1px solid #e5ddd1;
  vertical-align: top;
  text-align: left;
}

.badge {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
}

.badge-recommendation {
  background: #ece7da;
  color: #5b4d2a;
}

.badge-draft {
  background: #ece7da;
  color: #5b4d2a;
}

.badge-verified {
  background: var(--success-soft);
  color: var(--success);
}

.badge-archived {
  background: #efe7e5;
  color: #7a534a;
}

.detail-list {
  display: grid;
  gap: 0.9rem;
  margin: 0;
}

.detail-list div {
  display: grid;
  gap: 0.2rem;
}

.detail-list dt {
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
}

.compact-detail-list {
  gap: 0.6rem;
}

.field-error {
  margin: 0;
  color: var(--danger);
}

.preformatted {
  white-space: pre-wrap;
}

.score-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1rem 0;
}

.score-card,
.fact-card {
  border: 1px solid #e5ddd1;
  border-radius: 0.7rem;
  background: #fff;
  padding: 0.9rem;
}

.score-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.25rem;
}

.fact-card-verified {
  border-color: #b8d5b8;
  background: #f7fbf7;
}

.filters-panel {
  margin-bottom: 0.75rem;
}

.summary-card {
  padding: 0.7rem 0.85rem;
  gap: 0.15rem;
  min-height: 0;
}

.summary-card strong {
  display: block;
  margin: 0.1rem 0 0;
  font-size: 1.55rem;
  line-height: 1;
}

.summary-label,
.discovery-company,
.discovery-fit-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.discovery-page-header,
.discovery-stats-grid,
.discovery-queue,
.discovery-stack,
.discovery-filter-form,
.discovery-row-grid,
.discovery-expanded,
.discovery-expanded-grid,
.discovery-expanded-side,
.discovery-secondary-actions {
  display: grid;
}

.discovery-page-header,
.discovery-queue,
.discovery-filter-form,
.discovery-expanded,
.discovery-expanded-grid,
.discovery-expanded-side,
.discovery-secondary-actions {
  gap: 0.75rem;
}

.discovery-stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.7rem;
}

.discovery-filters-panel {
  padding: 0.95rem;
  margin-bottom: 0.8rem;
}

.discovery-filters-header h2,
.discovery-queue-header h2,
.discovery-description h4,
.discovery-primary h3 {
  margin: 0;
}

.discovery-page-header {
  padding: 0.85rem 0;
}

.discovery-page-header h1,
.discovery-filters-header h2,
.discovery-queue-header h2 {
  margin: 0;
}

.discovery-filters-header .muted,
.discovery-queue-header .muted,
.discovery-page-header .muted {
  margin: 0.18rem 0 0;
}

.discovery-queue-header {
  margin-bottom: 0.25rem;
}

.filter-actions {
  display: flex;
  align-items: end;
}

.discovery-item {
  padding: 0;
  overflow: hidden;
}

.discovery-stack {
  gap: 0.5rem;
}

.discovery-item summary {
  list-style: none;
}

.discovery-item summary::-webkit-details-marker {
  display: none;
}

.discovery-summary {
  padding: 0.8rem 1rem;
  cursor: pointer;
}

.discovery-summary:focus-visible {
  outline: 3px solid rgba(15, 95, 87, 0.28);
  outline-offset: -3px;
}

.discovery-row-grid {
  grid-template-columns: 4.8rem minmax(250px, 1.7fr) minmax(220px, 1.25fr) minmax(120px, 0.7fr) minmax(195px, auto) 1rem;
  gap: 0.9rem;
  align-items: center;
}

.discovery-fit-block,
.discovery-primary,
.discovery-summary-meta,
.discovery-summary-evaluation,
.discovery-summary-disclosure {
  display: grid;
}

.discovery-fit-block,
.discovery-summary-evaluation,
.discovery-summary-disclosure {
  align-items: center;
}

.discovery-fit-block {
  gap: 0.1rem;
  align-content: center;
  justify-items: center;
  min-height: 4.25rem;
  padding: 0.5rem 0.45rem;
  border: 1px solid #e5ddd1;
  border-radius: 0.7rem;
  background: #fbfaf6;
  text-align: center;
}

.discovery-fit-block strong {
  font-size: 1.2rem;
  line-height: 1;
}

.discovery-fit-strong-recommend {
  background: #dfefdf;
  color: var(--success);
  border-color: #b8d5b8;
}

.discovery-fit-recommend {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #bddad3;
}

.discovery-fit-hold {
  background: #ece7da;
  color: #6f5620;
  border-color: #d7ceb9;
}

.discovery-fit-decline,
.discovery-fit-unscored {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #dfb9b2;
}

.discovery-primary,
.discovery-summary-meta {
  gap: 0.24rem;
  align-content: start;
  min-width: 0;
}

.discovery-primary h3,
.discovery-summary-meta p {
  margin: 0;
}

.discovery-primary h3 {
  font-size: 1.02rem;
  line-height: 1.18;
}

.discovery-summary-meta p,
.discovery-expanded-meta dd {
  overflow-wrap: anywhere;
}

.discovery-inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.16rem 0.4rem;
  align-items: center;
  font-size: 0.9rem;
  line-height: 1.22;
}

.discovery-inline-meta-qualifier {
  font-size: 0.82rem;
}

.discovery-meta-separator {
  color: var(--muted);
  font-weight: 700;
}

.discovery-summary-evaluation {
  justify-items: start;
}

.discovery-summary-evaluation .badge {
  font-size: 0.82rem;
  line-height: 1.1;
}

.discovery-summary-actions {
  display: grid;
  gap: 0.28rem;
  justify-items: start;
  align-content: center;
  min-width: 0;
}

.discovery-summary-actions .badge-status {
  font-size: 0.82rem;
  line-height: 1.1;
}

.discovery-summary-actions .discovery-inline-controls {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  min-width: 0;
}

.discovery-summary-actions .discovery-inline-controls select,
.discovery-summary-actions .discovery-inline-controls button {
  min-height: 1.9rem;
  font-size: 0.87rem;
}

.discovery-summary-actions .discovery-inline-controls select {
  width: auto;
  min-width: 7rem;
  padding: 0.28rem 0.5rem;
}

.discovery-summary-actions .discovery-inline-controls button {
  padding: 0.3rem 0.65rem;
}

.discovery-summary-disclosure {
  justify-items: end;
  min-width: 1rem;
}

.discovery-chevron {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 120ms ease;
}

.discovery-item[open] .discovery-chevron {
  transform: rotate(180deg);
}

.badge-eligibility-good {
  background: var(--success-soft);
  color: var(--success);
}

.badge-eligibility-caution {
  background: #ece7da;
  color: #6f5620;
}

.badge-eligibility-risk {
  background: var(--danger-soft);
  color: var(--danger);
}

.discovery-expanded {
  border-top: 1px solid #e5ddd1;
  padding: 1.35rem 1.6rem 1.45rem;
  gap: 0.9rem;
}

.discovery-expanded-grid {
  grid-template-columns: minmax(0, 1.75fr) minmax(240px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.discovery-expanded-side {
  gap: 0.75rem;
}

.discovery-expanded-meta {
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.discovery-expanded-meta div {
  gap: 0.12rem;
}

.discovery-expanded-meta dt {
  font-size: 0.8rem;
  color: var(--muted);
}

.discovery-expanded-meta dd {
  font-size: 0.92rem;
  line-height: 1.3;
}

.discovery-description {
  border: 1px solid #e5ddd1;
  border-radius: 0.7rem;
  background: #fff;
  padding: 1rem 1.05rem;
}

.discovery-description .preformatted {
  margin: 0.45rem 0 0;
  font-size: 0.95rem;
  line-height: 1.42;
}

.discovery-secondary-actions {
  gap: 0.45rem;
}

.discovery-secondary-actions .button-link {
  min-height: 1.95rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.88rem;
}

.discovery-filter-form {
  gap: 0.75rem;
}

.discovery-filter-form .field-group {
  gap: 0.25rem;
}

.discovery-filter-form label {
  font-size: 0.86rem;
}

.discovery-filters-panel input,
.discovery-filters-panel select,
.discovery-filters-panel button {
  min-height: 2.15rem;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

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

.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.wrap-actions {
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .header-row,
  .page-header,
  .section-row,
  .actions-row,
  .inline-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-list {
    flex-wrap: wrap;
  }

  .filter-form,
  .field-grid,
  .detail-grid,
  .facts-layout,
  .score-grid,
  .checkbox-grid,
  .filter-form-wide {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .discovery-stats-grid,
  .discovery-expanded-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .discovery-row-grid {
    grid-template-columns: 4.5rem minmax(220px, 1.5fr) minmax(190px, 1.1fr) minmax(115px, 0.7fr) minmax(185px, auto) 1rem;
  }
}

@media (max-width: 900px) {
  .discovery-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .discovery-row-grid {
    grid-template-columns: 4.25rem minmax(0, 1.5fr) minmax(0, 1.05fr) auto;
    align-items: start;
  }

  .discovery-fit-block {
    grid-row: 1 / span 2;
  }

  .discovery-primary {
    grid-column: 2;
  }

  .discovery-summary-meta {
    grid-column: 3;
  }

  .discovery-summary-evaluation {
    grid-column: 2;
  }

  .discovery-summary-actions {
    grid-column: 3;
    justify-self: start;
  }

  .discovery-summary-disclosure {
    grid-column: 4;
    align-self: center;
  }

  .discovery-expanded-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .discovery-row-grid,
  .discovery-summary,
  .discovery-expanded-grid {
    grid-template-columns: 1fr;
  }

  .discovery-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .discovery-fit-block,
  .discovery-primary,
  .discovery-summary-meta,
  .discovery-summary-evaluation,
  .discovery-summary-actions {
    grid-column: auto;
  }

  .discovery-summary-actions,
  .filter-actions {
    justify-items: stretch;
  }

  .discovery-summary-actions .discovery-inline-controls {
    width: 100%;
    display: grid;
  }

  .discovery-summary-actions .discovery-inline-controls select,
  .discovery-summary-actions .discovery-inline-controls button {
    width: 100%;
  }

  .discovery-summary-disclosure {
    grid-column: auto;
    justify-items: end;
  }

  .discovery-expanded {
    padding: 1rem 1rem 1.1rem;
  }
}
