:root {
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --ink: #111827;
  --muted: #5d6673;
  --line: #d6dde5;
  --line-strong: #aeb8c3;
  --blue: #1f5f87;
  --blue-soft: #e7f1f7;
  --green: #136c4a;
  --green-soft: #e7f4ed;
  --amber: #8a6200;
  --amber-soft: #fff4d8;
  --orange: #a34e06;
  --orange-soft: #fff0df;
  --red: #b42318;
  --red-soft: #fff0ed;
  --purple: #5c4b99;
  --purple-soft: #f0edfb;
  --shadow: 0 12px 34px rgba(17, 24, 39, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(31, 95, 135, 0.12), rgba(31, 95, 135, 0) 250px),
    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;
}

.app-shell {
  width: min(1320px, 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: 2.02rem;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  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: 520px;
  color: var(--muted);
  line-height: 1.38;
  font-size: 0.88rem;
}

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

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

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

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

.checker-panel,
.summary-panel,
.results-panel,
.checklist-panel,
.copy-panel,
.later-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.results-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: 275px;
  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(--blue);
  box-shadow: 0 0 0 3px rgba(31, 95, 135, 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;
}

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

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

.metadata-panel legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 740;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 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;
  padding: 0 14px;
  font-weight: 760;
}

.primary-action {
  border: 1px solid #163f5b;
  background: var(--blue);
  color: #fff;
}

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

.ghost-action {
  border: 1px solid transparent;
  background: var(--surface-muted);
  color: var(--ink);
}

.primary-action:hover:not(:disabled),
.secondary-action:hover:not(:disabled),
.ghost-action:hover:not(:disabled) {
  filter: brightness(0.97);
}

.score-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 17px;
  background: var(--surface-muted);
}

.score-value {
  grid-row: span 2;
  min-width: 96px;
  font-size: 3.2rem;
  line-height: 0.95;
  font-weight: 820;
  letter-spacing: 0;
}

.score-label {
  font-size: 1rem;
  font-weight: 780;
}

.score-band {
  color: var(--muted);
  font-size: 0.9rem;
}

.state-low {
  background: var(--green-soft);
  border-color: rgba(19, 108, 74, 0.28);
}

.state-review {
  background: var(--amber-soft);
  border-color: rgba(138, 98, 0, 0.28);
}

.state-likely {
  background: var(--orange-soft);
  border-color: rgba(163, 78, 6, 0.28);
}

.state-high {
  background: var(--red-soft);
  border-color: rgba(180, 35, 24, 0.28);
}

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

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

.metric-list div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.metric-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 740;
}

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

.fact-list,
.scope-warning {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  color: var(--muted);
  line-height: 1.42;
  font-size: 0.88rem;
}

.fact-list {
  display: grid;
  gap: 8px;
  background: var(--blue-soft);
}

.fact-list p,
.scope-warning {
  margin: 0;
}

.scope-warning {
  margin-top: 12px;
  background: var(--surface-muted);
}

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

.result-status {
  display: inline-flex;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.25;
}

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

.findings-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

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

.findings-table th {
  background: var(--surface-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.findings-table td {
  font-size: 0.9rem;
}

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

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

.severity {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

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

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

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

.severity.info {
  background: var(--purple-soft);
  color: var(--purple);
}

.checklist {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.checklist li {
  padding-left: 4px;
  line-height: 1.44;
}

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

.later-panel {
  background: var(--surface);
}

.later-panel h2 {
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 720;
}

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

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

@media (max-width: 980px) {
  .topbar,
  .panel-heading-row {
    display: block;
  }

  .source-note {
    justify-content: flex-start;
    margin-top: 12px;
  }

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

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

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

  .result-status {
    margin-bottom: 14px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 14px;
  }

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

  .checker-panel,
  .summary-panel,
  .results-panel,
  .checklist-panel,
  .copy-panel,
  .later-panel {
    padding: 16px;
  }

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

  .input-meta {
    display: block;
  }

  .input-meta span + span {
    display: block;
    margin-top: 5px;
  }

  .score-box {
    grid-template-columns: 1fr;
  }

  .score-value {
    min-width: 0;
    font-size: 2.7rem;
  }

  .primary-action,
  .secondary-action,
  .ghost-action {
    width: 100%;
  }
}
