:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #20242a;
  --muted: #5d6673;
  --line: #dce1e8;
  --accent: #1d6f5f;
  --accent-strong: #0f4f45;
  --danger: #a33a2b;
  --warning: #8a5a12;
  --success: #226b3a;
  --shell-max-readable: 1080px;
  --shell-max-wide: 1800px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid #7cc7b9;
  outline-offset: 2px;
}

.skip-link {
  background: var(--accent-strong);
  color: var(--surface);
  font-weight: 700;
  left: 12px;
  padding: 8px 12px;
  position: absolute;
  text-decoration: none;
  top: -48px;
  z-index: 10;
}

.skip-link:focus {
  top: 12px;
}

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
}

.brand {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-link {
  border-radius: 6px;
  color: var(--muted);
  padding: 8px 10px;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active {
  background: #e5f2ef;
  color: var(--accent-strong);
}

.nav-link.is-active {
  font-weight: 700;
}

.app-main {
  margin: 0 auto;
  padding: 32px 16px;
  width: min(calc(100% - 32px), var(--shell-max-readable));
}

.app-main--wide {
  width: min(calc(100% - 32px), var(--shell-max-wide));
}

.app-main--readable {
  width: min(calc(100% - 32px), var(--shell-max-readable));
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 2rem;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0 0 8px;
}

.page-header p {
  color: var(--muted);
  margin: 0;
  max-width: 680px;
}

.status-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 18px;
  text-decoration: none;
}

.status-card:hover {
  border-color: var(--accent);
}

.status-card:focus-visible {
  border-color: var(--accent-strong);
}

.status-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-card strong {
  font-size: 1.1rem;
}

.dashboard-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 16px;
}

.dashboard-summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  text-decoration: none;
}

.dashboard-summary-card strong {
  color: var(--accent-strong);
  font-size: 1.6rem;
  line-height: 1;
}

.dashboard-summary-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.dashboard-controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 14px 16px;
}

.dashboard-search {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dashboard-search-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.dashboard-search input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  flex: 1 1 280px;
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
}

.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.filter-pill {
  align-items: center;
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  gap: 8px;
  padding: 7px 12px;
  text-decoration: none;
}

.filter-pill strong {
  color: var(--accent-strong);
  font-size: 0.92rem;
}

.filter-pill.is-active {
  background: #e5f2ef;
  border-color: #b7d9c1;
  color: var(--accent-strong);
  font-weight: 700;
}

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

.dashboard-table th,
.dashboard-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.dashboard-table th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

.dashboard-business {
  min-width: 0;
}

.dashboard-preview,
.dashboard-assets,
.dashboard-reasons {
  min-width: 0;
}

.asset-links {
  display: grid;
  gap: 8px;
}

.asset-link-group {
  display: grid;
  gap: 2px;
}

.reason-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.reason-chip {
  background: #eef2f6;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-block;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 2px 8px;
}

.status-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  max-width: 720px;
}

.status-list div {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(160px, 220px) 1fr;
  padding: 14px 18px;
}

.status-list div + div {
  border-top: 1px solid var(--line);
}

.status-list dt {
  color: var(--muted);
  font-weight: 600;
}

.status-list dd {
  margin: 0;
}

.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
  overflow-x: auto;
}

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

.lead-table th,
.lead-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.lead-table th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

.entity-link {
  color: var(--accent-strong);
  display: inline-block;
  font-weight: 700;
  text-decoration: none;
}

.entity-link:hover,
.back-link:hover {
  text-decoration: underline;
}

.meta-text {
  color: var(--muted);
  display: block;
  font-size: 0.85rem;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.workflow-status-cell {
  min-width: 0;
}

.workflow-status-inline {
  align-items: center;
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
}

.workflow-status-action {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  white-space: nowrap;
}

.score-pill,
.classification-pill {
  background: #eef2f6;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 2px 9px;
  white-space: nowrap;
}

.score-high,
.classification-high {
  background: #e7f4eb;
  border-color: #b7d9c1;
  color: var(--success);
}

.score-medium,
.classification-medium {
  background: #fff5df;
  border-color: #e8cf93;
  color: var(--warning);
}

.score-low,
.classification-low {
  background: #fbecea;
  border-color: #e4bbb4;
  color: var(--danger);
}

.score-unknown,
.classification-unknown {
  background: #eef2f6;
  border-color: var(--line);
  color: var(--muted);
}

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

.status-pill {
  background: #eef2f6;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 2px 9px;
  white-space: nowrap;
}

.status-completed,
.status-approved,
.status-exported,
.status-audited,
.status-packet-approved,
.status-packet-exported {
  background: #e7f4eb;
  border-color: #b7d9c1;
  color: var(--success);
}

.status-not-audited,
.status-audit-queued,
.status-packet-draft {
  background: #edf4fb;
  border-color: #bdd4ea;
  color: #285d8f;
}

.status-new,
.status-audit-pending {
  background: #edf4fb;
  border-color: #bdd4ea;
  color: #285d8f;
}

.status-needs-review,
.status-follow-up {
  background: #fff5df;
  border-color: #e8cf93;
  color: var(--warning);
}

.status-good-fit {
  background: #e7f4eb;
  border-color: #b7d9c1;
  color: var(--success);
}

.status-hold {
  background: #f1f1f1;
  border-color: #d4d4d4;
  color: #555555;
}

.status-not-fit {
  background: #fbecea;
  border-color: #e4bbb4;
  color: var(--danger);
}

.status-running,
.status-draft,
.status-audit-running,
.status-packet-draft {
  background: #edf4fb;
  border-color: #bdd4ea;
  color: #285d8f;
}

.status-crawl-analysis-in-progress {
  background: #edf4fb;
  border-color: #bdd4ea;
  color: #285d8f;
}

.status-pending,
.status-needs-revision,
.status-audit-pending {
  background: #fff5df;
  border-color: #e8cf93;
  color: var(--warning);
}

.status-failed,
.status-rejected,
.status-audit-failed {
  background: #fbecea;
  border-color: #e4bbb4;
  color: var(--danger);
}

.status-skipped,
.status-held-excluded,
.status-not-crawl-eligible {
  background: #f1f1f1;
  border-color: #d4d4d4;
  color: #555555;
}

.status-cannot-audit-no-website {
  background: #f1f1f1;
  border-color: #d4d4d4;
  color: #555555;
}

@media (max-width: 900px) {
  .workflow-status-inline {
    flex-wrap: wrap;
  }
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.empty-state h2 {
  font-size: 1.2rem;
  margin: 0 0 6px;
}

.empty-state p {
  color: var(--muted);
  margin: 0 0 8px;
}

.empty-state p:last-child {
  margin-bottom: 0;
}

.empty-next {
  color: var(--text);
  font-weight: 650;
}

.operator-message,
.operator-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 14px 16px;
}

.operator-message-success {
  border-color: #b7d9c1;
  color: var(--success);
}

.operator-message-error {
  border-color: #e4bbb4;
  color: var(--danger);
}

.operator-panel {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.operator-panel--stacked {
  align-items: stretch;
  display: grid;
  gap: 16px;
}

.operator-panel h2 {
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.operator-panel p {
  color: var(--muted);
  margin: 0;
  max-width: 720px;
}

.operator-panel .operator-detail {
  color: var(--text);
  font-size: 0.9rem;
  margin-top: 6px;
}

.discovery-form {
  display: grid;
  gap: 14px;
}

.discovery-field {
  display: grid;
  gap: 8px;
}

.discovery-field textarea,
.discovery-field input[type="number"],
.discovery-field select {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

.discovery-field textarea {
  min-height: 108px;
  resize: vertical;
}

.discovery-areas {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.discovery-profile-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.discovery-profile-details summary {
  cursor: pointer;
  list-style: none;
}

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

.discovery-profile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.discovery-areas legend {
  padding: 0 6px;
}

.discovery-area-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.back-link {
  color: var(--accent-strong);
  display: inline-block;
  font-weight: 700;
  margin-bottom: 12px;
  text-decoration: none;
}

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

.detail-grid > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.detail-label {
  color: var(--muted);
  display: block;
  font-size: 0.88rem;
  margin-bottom: 5px;
}

.detail-grid strong {
  display: block;
  font-weight: 650;
  overflow-wrap: anywhere;
}

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

.review-section {
  margin-top: 28px;
}

.review-section h2 {
  font-size: 1.3rem;
  margin: 0 0 12px;
}

.section-note {
  color: var(--muted);
  margin: -4px 0 14px;
  max-width: 760px;
}

.lead-review-form {
  display: grid;
  gap: 14px;
}

.review-input,
.review-textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 8px 10px;
  width: 100%;
}

.review-textarea {
  min-height: 120px;
  resize: vertical;
}

.checkbox-row {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-height: 40px;
}

.error-state h1,
.error-text {
  color: var(--danger);
}

.score-summary {
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  padding: 16px;
}

.score-summary strong {
  color: var(--accent-strong);
  font-size: 2rem;
  line-height: 1;
}

.score-summary span {
  color: var(--muted);
  font-weight: 700;
}

.finding-list,
.artifact-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.finding-list li,
.artifact-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.finding-list strong,
.artifact-list strong,
.artifact-list span {
  display: block;
  overflow-wrap: anywhere;
}

.finding-list p,
.artifact-list p {
  color: var(--muted);
  margin: 6px 0 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row form {
  margin: 0;
}

.action-stack {
  display: grid;
  gap: 10px;
}

.action-button {
  background: var(--accent-strong);
  border: 1px solid var(--accent-strong);
  border-radius: 6px;
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  min-height: 40px;
  padding: 8px 12px;
}

.action-link {
  text-decoration: none;
}

.action-button-secondary {
  background: #f7f8fa;
  border-color: var(--line);
  color: var(--text);
}

.action-button-muted {
  background: #eef2f6;
  border-color: var(--line);
  color: var(--muted);
}

.action-button:disabled {
  background: #eef2f6;
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
}

.markdown-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  margin: 0;
  overflow-x: auto;
  padding: 16px;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px;
  }

  .app-main {
    padding: 24px 18px;
    width: min(calc(100% - 24px), var(--shell-max-readable));
  }

  .status-list div {
    grid-template-columns: 1fr;
  }

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

  .dashboard-search {
    align-items: stretch;
  }

  .operator-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}
