:root {
  --page: #f5f7f4;
  --panel: #ffffff;
  --ink: #1d2525;
  --muted: #61706c;
  --line: #d9e0dc;
  --soft: #eef3ef;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --green: #2f7d45;
  --amber: #b36b00;
  --red: #b42318;
  --focus: #2563eb;
  --shadow: 0 18px 42px rgba(29, 37, 37, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 320px),
    var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--teal-dark);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1,
.results-bar h2,
.section-heading h2 {
  margin: 0;
  line-height: 1.08;
}

.topbar h1 {
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 750;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(380px, 1fr) minmax(300px, 380px);
  gap: 18px;
  padding: 18px;
  max-width: 1520px;
  margin: 0 auto;
}

.filters,
.results,
.detail-sticky {
  min-width: 0;
}

.filters,
.results,
.job-detail,
.optimizer,
.resume-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.filters {
  padding: 14px;
  align-self: start;
}

.filter-form,
.resume-input {
  display: grid;
  gap: 14px;
}

.resume-input {
  margin-top: 14px;
  padding: 14px;
  box-shadow: none;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.sort-control select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

.field textarea {
  resize: vertical;
  min-height: 210px;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.sort-control select:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  border-color: var(--focus);
}

.segmented,
.skill-grid {
  border: 0;
  padding: 0;
  margin: 0;
}

.segmented legend,
.skill-grid legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.segmented legend {
  grid-column: 1 / -1;
}

.segmented label,
.skill-grid label,
.checkbox-row {
  position: relative;
  min-width: 0;
}

.segmented input,
.skill-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span,
.skill-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  padding: 6px 8px;
  overflow-wrap: anywhere;
}

.segmented input:checked + span,
.skill-grid input:checked + span {
  border-color: rgba(15, 118, 110, 0.5);
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-dark);
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.skill-grid legend {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.button-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.ghost-link {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
  min-height: 42px;
}

.primary {
  background: var(--teal);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.secondary,
.ghost-link {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary:hover:not(:disabled),
.ghost-link:hover {
  border-color: rgba(15, 118, 110, 0.45);
  color: var(--teal-dark);
}

.full-width {
  width: 100%;
}

.results {
  padding: 14px;
  min-height: 720px;
}

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.sort-control select {
  min-width: 148px;
  padding: 8px 10px;
}

.live-status {
  min-height: 38px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.job-list {
  display: grid;
  gap: 10px;
}

.job-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
  text-align: left;
  color: var(--ink);
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.job-card:hover,
.job-card.is-active {
  border-color: rgba(15, 118, 110, 0.6);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.11);
  transform: translateY(-1px);
}

.job-card h3 {
  margin: 0 0 7px;
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.job-meta,
.tag-row,
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.job-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.match-row {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 10px;
  align-items: center;
  margin: 9px 0 10px;
}

.match-score {
  font-weight: 850;
  color: var(--teal-dark);
}

.meter {
  height: 8px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: var(--score-width, 0%);
  background: linear-gradient(90deg, var(--green), var(--teal));
}

.tag,
.source-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 25px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.source-tag {
  background: rgba(179, 107, 0, 0.1);
  color: var(--amber);
}

.job-summary {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.detail-sticky {
  display: grid;
  gap: 14px;
  align-self: start;
  position: sticky;
  top: 98px;
}

.job-detail,
.optimizer {
  padding: 14px;
}

.job-detail h2 {
  margin: 0 0 7px;
  line-height: 1.18;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.detail-company {
  color: var(--muted);
  margin: 0 0 10px;
}

.detail-meta {
  margin: 10px 0;
}

.detail-description {
  margin-top: 14px;
  max-height: 240px;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: #34413e;
  line-height: 1.52;
  font-size: 14px;
}

.empty-state,
.error-state {
  color: var(--muted);
  line-height: 1.48;
  margin: 0;
}

.error-state {
  color: var(--red);
}

.optimizer {
  display: grid;
  gap: 12px;
}

.optimizer-output {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #263230;
}

.optimizer-output.is-error {
  border-color: rgba(180, 35, 24, 0.35);
  background: rgba(180, 35, 24, 0.04);
  color: var(--red);
}

.optimizer-actions {
  justify-content: flex-end;
}

.skeleton {
  height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(90deg, #fff, #edf3ef, #fff);
  background-size: 220% 100%;
  animation: shimmer 1200ms linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 0 0;
  }
  to {
    background-position: -220% 0;
  }
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  }

  .detail {
    grid-column: 1 / -1;
  }

  .detail-sticky {
    position: static;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
  }
}

@media (min-width: 1181px) {
  .detail-sticky {
    max-height: calc(100vh - 116px);
    overflow: auto;
    padding-right: 3px;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .status-pill {
    max-width: none;
    width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .detail-sticky {
    grid-template-columns: 1fr;
  }

  .results-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .sort-control {
    width: 100%;
  }

  .sort-control select {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .segmented {
    grid-template-columns: 1fr;
  }

  .skill-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button,
  .ghost-link {
    width: 100%;
  }
}
