:root {
  --page: #f5f6f7;
  --surface: #ffffff;
  --surface-muted: #eef2f3;
  --ink: #111817;
  --muted: #596461;
  --line: #d5dddb;
  --line-strong: #aebbb8;
  --teal: #0f6f63;
  --teal-soft: #e4f4f1;
  --blue: #245d9a;
  --blue-soft: #e8f1fb;
  --green: #17633f;
  --green-soft: #e5f2ea;
  --amber: #8b6500;
  --amber-soft: #fff4d7;
  --orange: #a04f10;
  --orange-soft: #fff0e3;
  --red: #b42318;
  --red-soft: #fff0ed;
  --violet: #61539b;
  --violet-soft: #f0eef9;
  --shadow: 0 12px 34px rgba(17, 24, 23, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(15, 111, 99, 0.12), rgba(15, 111, 99, 0) 260px),
    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(1360px, 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(--teal);
  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: 540px;
  color: var(--muted);
  line-height: 1.38;
  font-size: 0.88rem;
}

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

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

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

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

.planner-panel,
.summary-panel,
.results-panel,
.runbook-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: 300px;
  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(--teal);
  box-shadow: 0 0 0 3px rgba(15, 111, 99, 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: 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;
}

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

.primary-action:hover {
  background: #0b5f55;
}

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

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

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

.ghost-action:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.score-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 14px;
  align-items: center;
  min-height: 116px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 18px;
}

.score-value {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 999px;
  background: #ffffff;
  border: 8px solid var(--line-strong);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0;
}

.score-label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 760;
}

.score-band {
  min-width: 0;
  font-size: 1.08rem;
  font-weight: 780;
  line-height: 1.25;
}

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

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

.score-box.state-low .score-value {
  border-color: var(--green);
}

.score-box.state-planning {
  background: var(--amber-soft);
}

.score-box.state-planning .score-value {
  border-color: var(--amber);
}

.score-box.state-rehearsal {
  background: var(--orange-soft);
}

.score-box.state-rehearsal .score-value {
  border-color: var(--orange);
}

.score-box.state-high {
  background: var(--red-soft);
}

.score-box.state-high .score-value {
  border-color: var(--red);
}

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

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

.metric-list dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.metric-list dd {
  margin: 0;
  line-height: 1.25;
  font-size: 1.04rem;
  font-weight: 780;
}

.fact-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.fact-list p,
.scope-warning {
  margin: 0;
  border-left: 4px solid var(--teal);
  background: var(--teal-soft);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.42;
}

.scope-warning {
  margin-top: 16px;
  border-left-color: var(--red);
  background: var(--red-soft);
}

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

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

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

.findings-table {
  width: 100%;
  min-width: 980px;
  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.38;
}

.findings-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

.findings-table td:nth-child(2),
.findings-table td:nth-child(3) {
  font-family: "IBM Plex Mono", "SFMono-Regular", "Cascadia Code", ui-monospace, monospace;
  font-size: 0.82rem;
}

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

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

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

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

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

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

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

.runbook-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 11px 12px;
  line-height: 1.42;
}

.copy-panel pre {
  min-height: 332px;
  max-height: 520px;
  overflow: auto;
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17201f;
  color: #edf7f4;
  padding: 14px;
  font-size: 0.83rem;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.later-panel {
  background: linear-gradient(135deg, var(--surface) 0%, #f7faf9 100%);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100% - 36px));
  border-radius: 8px;
  background: #17201f;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(17, 24, 23, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1080px) {
  .topbar,
  .planner-grid,
  .work-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

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

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

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

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

  .planner-panel,
  .summary-panel,
  .results-panel,
  .runbook-panel,
  .copy-panel,
  .later-panel {
    padding: 16px;
  }

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

  .input-meta,
  .panel-heading-row {
    display: grid;
  }

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

  .score-value {
    grid-row: auto;
    width: 76px;
    height: 76px;
    font-size: 1.72rem;
  }

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