:root {
  --page: #f3f5f2;
  --surface: #ffffff;
  --surface-muted: #eef2ef;
  --ink: #121614;
  --muted: #5e6863;
  --line: #d7dfd9;
  --line-strong: #aeb9b2;
  --graph: #276d59;
  --graph-soft: #e3f2ec;
  --signal: #1f5f86;
  --signal-soft: #e3eff6;
  --amber: #8a6508;
  --amber-soft: #fff3cf;
  --red: #b3392e;
  --red-soft: #fff0eb;
  --steel: #293232;
  --shadow: 0 14px 36px rgba(18, 22, 20, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(39, 109, 89, 0.12), rgba(39, 109, 89, 0) 270px),
    linear-gradient(90deg, rgba(18, 22, 20, 0.038) 1px, transparent 1px),
    var(--page);
  background-size: auto, 34px 34px, auto;
}

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,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

a {
  color: var(--signal);
  text-underline-offset: 3px;
}

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

textarea,
pre,
td,
.score-band,
.compact-list li,
.work-list li,
.gap-grid li,
.result-status {
  overflow-wrap: anywhere;
}

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

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

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

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

.eyebrow {
  margin: 0 0 7px;
  color: var(--graph);
  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: 570px;
  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 {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(360px, 0.9fr);
  align-items: stretch;
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

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

.section-heading h2 {
  font-size: 1.18rem;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 0.84rem;
  font-weight: 740;
}

textarea {
  width: 100%;
  min-height: 322px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  padding: 13px 14px;
  font-size: 0.9rem;
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--graph);
  box-shadow: 0 0 0 3px rgba(39, 109, 89, 0.15);
}

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

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

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

.action-row,
.copy-toolbar,
.tab-bar,
.boundary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row {
  align-items: center;
  margin-top: 14px;
}

.primary-action,
.secondary-action,
.ghost-action,
.copy-button,
.tab-button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 740;
}

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

.secondary-action {
  border-color: var(--graph);
  background: var(--graph-soft);
  color: var(--graph);
}

.ghost-action {
  border-color: var(--line);
  background: var(--surface);
  color: var(--steel);
}

.summary-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.summary-layout {
  display: grid;
  grid-template-columns: minmax(130px, 0.72fr) minmax(150px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.score-box {
  display: flex;
  min-height: 154px;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
}

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

.score-label {
  display: block;
  margin-top: 9px;
  font-weight: 780;
}

.score-band {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.state-critical {
  border-color: rgba(179, 57, 46, 0.5);
  background: var(--red-soft);
}

.state-high {
  border-color: rgba(138, 101, 8, 0.55);
  background: var(--amber-soft);
}

.state-medium {
  border-color: rgba(31, 95, 134, 0.42);
  background: var(--signal-soft);
}

.state-low {
  border-color: rgba(39, 109, 89, 0.42);
  background: var(--graph-soft);
}

.state-empty {
  border-color: var(--line);
  background: var(--surface-muted);
}

.route-mark {
  position: relative;
  width: 100%;
  min-height: 154px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f9fbf9, #eef4f0);
}

.route-node {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 760;
}

.route-node-left {
  top: 22px;
  left: 12px;
}

.route-node-right {
  top: 22px;
  right: 12px;
}

.route-node-bottom {
  right: calc(50% - 56px);
  bottom: 20px;
  min-width: 112px;
}

.route-line {
  position: absolute;
  display: block;
  background: var(--signal);
}

.route-line-horizontal {
  top: 41px;
  left: 114px;
  right: 114px;
  height: 3px;
  border-radius: 999px;
}

.route-line-vertical {
  top: 45px;
  left: calc(50% - 1px);
  width: 3px;
  height: 47px;
  border-radius: 999px;
}

.route-dot {
  position: absolute;
  top: 34px;
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--graph);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

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

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

.metric-grid dd {
  margin: 6px 0 0;
  font-size: 1.08rem;
  font-weight: 800;
}

.summary-block h3,
.subpanel h3 {
  margin: 0 0 10px;
  font-size: 0.96rem;
}

.compact-list,
.work-list,
.gap-grid {
  margin: 0;
  padding-left: 18px;
}

.compact-list li,
.work-list li,
.gap-grid li {
  margin: 7px 0;
  line-height: 1.42;
}

.next-action {
  border-left: 4px solid var(--graph);
  border-radius: 6px;
  background: var(--graph-soft);
  padding: 12px 13px;
}

.next-action strong,
.next-action span {
  display: block;
}

.next-action span {
  margin-top: 4px;
  color: var(--steel);
  line-height: 1.42;
}

.scope-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.45;
}

.results-panel {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.result-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.tab-bar {
  margin: 0 0 14px;
}

.tab-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--steel);
}

.tab-button.is-active {
  border-color: var(--signal);
  background: var(--signal-soft);
  color: var(--signal);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.matrix-wrap {
  margin-top: 14px;
}

.matrix-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: var(--surface);
}

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

.matrix-table th {
  background: #f7f9f7;
  color: var(--steel);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.priority-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 0.78rem;
  font-weight: 780;
}

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

.priority-high {
  background: var(--amber-soft);
  color: var(--amber);
}

.priority-medium {
  background: var(--signal-soft);
  color: var(--signal);
}

.priority-low {
  background: var(--graph-soft);
  color: var(--graph);
}

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

.subpanel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.span-2 {
  grid-column: span 2;
}

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

.copy-toolbar {
  margin-bottom: 12px;
}

.copy-button {
  border-color: var(--graph);
  background: var(--graph-soft);
  color: var(--graph);
}

.artifact-preview {
  min-height: 320px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101614;
  color: #eaf0ed;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.48;
  font-size: 0.86rem;
}

.boundary-strip {
  justify-content: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.boundary-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  padding: 7px 10px;
}

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

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1060px) {
  .app-header,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

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

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

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

  .summary-layout {
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr);
  }
}

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

  .app-header h1 {
    font-size: 1.45rem;
  }

  .panel {
    padding: 16px;
  }

  textarea {
    min-height: 280px;
  }

  .input-meta {
    flex-direction: column;
    gap: 4px;
  }

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

  .summary-layout,
  .metric-grid,
  .checklist-grid,
  .gap-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

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

  .primary-action,
  .secondary-action,
  .ghost-action,
  .copy-button,
  .tab-button {
    flex: 1 1 140px;
  }
}
