:root {
  color-scheme: light;
  --page: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --surface-ink: #101820;
  --ink: #17202a;
  --muted: #5f6f77;
  --line: #d6ddd4;
  --line-strong: #aebbac;
  --blue: #1a5e8f;
  --blue-strong: #0c3e63;
  --blue-soft: #e4f1f8;
  --green: #246d55;
  --green-soft: #e4f4ed;
  --amber: #9a6614;
  --amber-soft: #fff1d8;
  --red: #ad3f35;
  --red-soft: #fae5e1;
  --violet: #6b547d;
  --violet-soft: #f0e8f4;
  --gray-soft: #eef2ef;
  --shadow: 0 18px 34px rgba(22, 32, 42, 0.08);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(26, 94, 143, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(36, 109, 85, 0.05) 1px, transparent 1px),
    var(--page);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: Aptos, "IBM Plex Sans", "Segoe UI", ui-sans-serif, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-width: 320px;
  margin: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
a,
textarea {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--blue);
  font-weight: 730;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--blue-strong);
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--gray-soft);
  color: #273747;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

h1,
h2,
h3,
p,
td,
th,
button,
textarea,
span,
strong,
dd,
dt,
li,
pre {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 1040px;
  font-size: clamp(1.18rem, 2vw, 1.7rem);
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.32;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.34;
  letter-spacing: 0;
}

.app-shell {
  width: min(1560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 34px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 0 2px 14px;
  border-bottom: 1px solid var(--line);
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.positioning {
  max-width: 1040px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.source-note {
  display: flex;
  flex: 0 1 540px;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  text-align: right;
}

.source-date {
  color: var(--ink);
  font-weight: 760;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(410px, 0.95fr);
  gap: 14px;
  min-height: min(700px, calc(100vh - 126px));
  padding: 14px 0;
}

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

.evidence-panel,
.summary-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.panel-heading,
.results-header,
.work-heading,
.copy-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.local-badge,
.status-chip,
.result-status,
.work-heading span {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 730;
  line-height: 1.2;
  overflow-wrap: normal;
  text-align: center;
  white-space: nowrap;
}

.field-label {
  margin: 16px 0 7px;
  color: #354255;
  font-size: 0.78rem;
  font-weight: 720;
}

.lens-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 560px);
  margin: 14px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.lens-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.lens-switch label {
  min-width: 0;
}

.lens-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lens-switch span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}

.lens-switch input:checked + span {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 5px 14px rgba(22, 32, 42, 0.06);
}

textarea {
  flex: 1;
  width: 100%;
  min-height: 330px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background:
    linear-gradient(180deg, rgba(26, 94, 143, 0.035), transparent 36%),
    #fbfcfd;
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.45;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 94, 143, 0.14);
}

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

.input-message {
  min-height: 20px;
  margin: 6px 0 0;
  color: var(--blue-strong);
  font-size: 0.76rem;
  font-weight: 720;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid rgba(26, 94, 143, 0.28);
  outline-offset: 2px;
}

.primary-action,
.secondary-action,
.ghost-action,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 820;
  line-height: 1.15;
}

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

.primary-action:hover {
  background: #263241;
}

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

.secondary-action:hover,
.ghost-action:hover,
.copy-button:hover {
  background: var(--gray-soft);
}

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

.button-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.78rem;
  line-height: 1;
}

.secondary-action .button-glyph,
.ghost-action .button-glyph {
  background: var(--gray-soft);
}

.summary-panel {
  gap: 14px;
}

.summary-heading {
  align-items: center;
}

.status-chip.status-low {
  border-color: #a8cdbb;
  background: var(--green-soft);
  color: var(--green);
}

.status-chip.status-medium {
  border-color: #e0c58e;
  background: var(--amber-soft);
  color: var(--amber);
}

.status-chip.status-high,
.status-chip.status-critical {
  border-color: #e5a49e;
  background: var(--red-soft);
  color: var(--red);
}

.status-chip.status-unknown {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.score-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.65fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.score-band.state-high,
.score-band.state-critical {
  border-left-color: var(--red);
  background: var(--red-soft);
}

.score-band.state-medium {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.score-band.state-low {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.score-band.state-empty {
  border-left-color: var(--line-strong);
  background: var(--surface-soft);
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 780;
}

.score-value {
  display: block;
  margin-top: 2px;
  font-size: clamp(1.15rem, 2vw, 1.8rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.score-facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.score-facts div,
.metric-grid div,
.deadline-strip div {
  min-width: 0;
}

.score-facts dt,
.metric-grid dt,
.deadline-strip span,
.next-action span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 760;
  text-transform: uppercase;
}

.score-facts dd,
.metric-grid dd {
  margin: 1px 0 0;
  color: var(--ink);
  font-weight: 760;
}

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

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

.metric-grid dd {
  font-size: 1.18rem;
  line-height: 1.1;
}

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

.deadline-strip div,
.next-action {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.deadline-strip strong,
.next-action strong {
  display: block;
  margin-top: 3px;
  font-size: 0.84rem;
  line-height: 1.25;
}

.next-action {
  border-left: 5px solid var(--blue);
}

.risk-note {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.privacy-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 16px;
}

.privacy-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 720;
}

.results-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.results-header {
  align-items: center;
  padding: 16px 18px 10px;
}

.tab-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 18px 10px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.tab-button.is-active {
  border-color: var(--surface-ink);
  background: var(--surface-ink);
  color: #ffffff;
}

.tab-panel {
  padding: 16px 18px 18px;
}

.tab-panel.is-hidden {
  display: none;
}

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

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

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.78rem;
}

th {
  background: var(--surface-soft);
  color: #3b4852;
  font-size: 0.71rem;
  font-weight: 840;
  text-transform: uppercase;
}

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 790;
  overflow-wrap: normal;
  white-space: nowrap;
}

.badge.high,
.badge.critical {
  border-color: #e6aaa1;
  background: var(--red-soft);
  color: var(--red);
}

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

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

.badge.info {
  border-color: #b7cbd8;
  background: var(--blue-soft);
  color: var(--blue-strong);
}

.work-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.work-heading {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.sequence-list,
.work-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 14px 14px 14px 32px;
}

.sequence-list li,
.work-list li {
  padding-left: 4px;
  font-size: 0.82rem;
}

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

.risk-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.risk-card h3 {
  margin-bottom: 6px;
}

.risk-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.copy-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.copy-heading {
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.copy-button {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

pre {
  min-height: 132px;
  max-height: 280px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  color: #263241;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 1120px) {
  .app-header,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: grid;
    align-items: start;
  }

  .source-note {
    align-items: flex-start;
    text-align: left;
  }

  .tool-grid {
    min-height: 0;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1560px);
    padding-top: 10px;
  }

  .app-header {
    gap: 10px;
    min-height: 0;
  }

  .tool-grid {
    gap: 10px;
    padding: 10px 0;
  }

  .evidence-panel,
  .summary-panel,
  .results-header,
  .tab-panel {
    padding: 12px;
  }

  .tab-bar {
    padding: 0 12px 10px;
  }

  .panel-heading,
  .results-header,
  .work-heading,
  .copy-heading {
    gap: 8px;
  }

  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  .results-header .result-status {
    justify-content: flex-start;
    width: 100%;
    overflow-wrap: anywhere;
    text-align: left;
    white-space: normal;
  }

  .lens-switch,
  .metric-grid,
  .deadline-strip,
  .score-band,
  .copy-grid,
  .risk-grid {
    grid-template-columns: 1fr;
  }

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

  textarea {
    min-height: 270px;
    font-size: 0.8rem;
  }

  table {
    min-width: 690px;
  }
}
