:root {
  --page: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #edf2ef;
  --ink: #101514;
  --muted: #5a6662;
  --line: #d5ded9;
  --line-strong: #aebbb4;
  --green: #176347;
  --green-soft: #e4f3eb;
  --blue: #255f99;
  --blue-soft: #e7f0fb;
  --amber: #8b6400;
  --amber-soft: #fff4d7;
  --orange: #a34d0e;
  --orange-soft: #fff0e3;
  --red: #b42318;
  --red-soft: #fff0ed;
  --violet: #5c5795;
  --violet-soft: #f0eef8;
  --shadow: 0 12px 34px rgba(16, 21, 20, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(23, 99, 71, 0.12), rgba(23, 99, 71, 0) 265px),
    var(--page);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Aptos", "IBM Plex Sans", "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

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

button {
  cursor: pointer;
}

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

a {
  color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

code,
pre,
textarea {
  font-family: "IBM Plex Mono", "SFMono-Regular", "Cascadia Code", ui-monospace, monospace;
}

code,
.snippet,
.inventory-group strong,
.fact-list p,
.gap-list li,
.plan-list li {
  overflow-wrap: anywhere;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 0 18px;
}

.topbar h1,
.section-heading h2,
.later-panel h2 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 760;
}

.topbar h1 {
  max-width: 780px;
  font-size: 2rem;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

.source-note {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px 12px;
  max-width: 560px;
  color: var(--muted);
  line-height: 1.38;
  font-size: 0.88rem;
}

.source-note strong {
  flex-basis: 100%;
  color: var(--ink);
  text-align: right;
}

.mapper-grid,
.work-grid {
  display: grid;
  gap: 16px;
}

.mapper-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(365px, 0.9fr);
  align-items: stretch;
}

.work-grid {
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  margin-top: 16px;
}

.mapper-panel,
.summary-panel,
.results-panel,
.inventory-panel,
.plan-panel,
.copy-panel,
.gaps-panel,
.later-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.results-panel,
.inventory-panel,
.gaps-panel,
.later-panel {
  margin-top: 16px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2,
.later-panel h2 {
  font-size: 1.2rem;
}

.field-label,
.metadata-panel span {
  display: block;
  margin: 15px 0 7px;
  font-size: 0.84rem;
  font-weight: 740;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 286px;
  resize: vertical;
  padding: 13px 14px;
  font-size: 0.9rem;
  line-height: 1.5;
}

input,
select {
  min-height: 40px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 99, 71, 0.15);
}

.input-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.input-meta span:last-child {
  text-align: right;
}

.field-hint {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--red);
  font-size: 0.86rem;
}

.metadata-panel {
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px 16px;
}

.metadata-panel legend {
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
}

.action-row,
.copy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.primary-action,
.secondary-action,
.ghost-action {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 760;
  letter-spacing: 0;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-action {
  background: var(--green);
  color: #fff;
  box-shadow: 0 9px 20px rgba(23, 99, 71, 0.22);
}

.secondary-action {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: var(--ink);
}

.ghost-action {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.primary-action:hover:not(:disabled),
.secondary-action:hover:not(:disabled),
.ghost-action:hover:not(:disabled) {
  transform: translateY(-1px);
}

.score-box {
  display: grid;
  gap: 6px;
  border-radius: 8px;
  padding: 18px;
  background: var(--surface-muted);
}

.score-value {
  display: block;
  font-size: 3.6rem;
  line-height: 1;
  font-weight: 820;
}

.score-label,
.score-band {
  display: block;
  font-weight: 760;
}

.score-band {
  font-size: 0.92rem;
}

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

.state-low {
  background: var(--green-soft);
  color: var(--green);
}

.state-plan {
  background: var(--blue-soft);
  color: var(--blue);
}

.state-sprint {
  background: var(--amber-soft);
  color: var(--amber);
}

.state-critical {
  background: var(--red-soft);
  color: var(--red);
}

.metric-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.metric-list div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: #fbfcfb;
}

.metric-list dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 760;
  text-transform: uppercase;
}

.metric-list dd {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 780;
}

.fact-list {
  display: grid;
  gap: 9px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

.fact-list p,
.scope-warning,
.later-panel p,
.copy-note {
  margin: 0;
}

.scope-warning {
  border-left: 3px solid var(--amber);
  padding: 9px 0 9px 12px;
  color: var(--muted);
  line-height: 1.44;
  font-size: 0.9rem;
}

.panel-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.result-status {
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 760;
  white-space: nowrap;
}

.table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.matrix-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.matrix-table th,
.matrix-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

.matrix-table th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 790;
  text-transform: uppercase;
}

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

.snippet {
  display: inline-block;
  max-width: 430px;
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", "Cascadia Code", ui-monospace, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.78rem;
  font-weight: 780;
  white-space: nowrap;
}

.badge.high {
  background: var(--red-soft);
  color: var(--red);
}

.badge.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.low {
  background: var(--green-soft);
  color: var(--green);
}

.badge.info {
  background: var(--blue-soft);
  color: var(--blue);
}

.muted-inline {
  color: var(--muted);
  font-size: 0.8rem;
}

.empty-row td,
.inventory-empty {
  color: var(--muted);
  font-style: italic;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.inventory-group {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.inventory-group h3 {
  margin: 0 0 10px;
  font-size: 0.96rem;
}

.inventory-group ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  min-width: 0;
  color: var(--muted);
  line-height: 1.36;
}

.inventory-group li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.inventory-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 14px;
}

.plan-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
  line-height: 1.45;
}

.plan-list li::marker {
  color: var(--green);
  font-weight: 780;
}

.copy-panel {
  min-width: 0;
}

.copy-actions .secondary-action {
  flex: 1 1 210px;
}

.artifact-preview {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  margin: 16px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101514;
  color: #edf2ef;
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  line-height: 1.48;
}

.copy-note {
  color: var(--muted);
  font-size: 0.86rem;
}

.gap-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 20px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.42;
}

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

.later-panel p {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(18px);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1080px) {
  .topbar,
  .later-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-note {
    justify-content: flex-start;
  }

  .source-note strong {
    text-align: left;
  }

  .mapper-grid,
  .work-grid,
  .inventory-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1380px);
    padding-top: 16px;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .mapper-panel,
  .summary-panel,
  .results-panel,
  .inventory-panel,
  .plan-panel,
  .copy-panel,
  .gaps-panel,
  .later-panel {
    padding: 16px;
  }

  .field-grid,
  .metric-list,
  .gap-list {
    grid-template-columns: 1fr;
  }

  .input-meta,
  .panel-heading-row {
    flex-direction: column;
  }

  .input-meta span:last-child {
    text-align: left;
  }

  .result-status {
    white-space: normal;
  }

  .matrix-table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .matrix-table thead {
    display: none;
  }

  .matrix-table tbody,
  .matrix-table tr,
  .matrix-table td {
    display: block;
    width: 100%;
  }

  .matrix-table tr {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }

  .matrix-table td {
    border-bottom: 0;
    padding: 6px 0;
  }

  .matrix-table td::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 790;
    text-transform: uppercase;
  }

  .matrix-table td:nth-child(1)::before {
    content: "Version";
  }

  .matrix-table td:nth-child(2)::before {
    content: "Evidence snippet";
  }

  .matrix-table td:nth-child(3)::before {
    content: "Service or method";
  }

  .matrix-table td:nth-child(4)::before {
    content: "Environment";
  }

  .matrix-table td:nth-child(5)::before {
    content: "Urgency";
  }

  .matrix-table td:nth-child(6)::before {
    content: "Recommended next action";
  }

  textarea {
    min-height: 230px;
  }

  .score-value {
    font-size: 3rem;
  }

  .toast {
    right: 10px;
    left: 10px;
    max-width: none;
    width: auto;
  }
}
