:root {
  color-scheme: light;
  --page: #f4f5f1;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --surface-tint: #eef6f0;
  --ink: #18211b;
  --muted: #5e6a62;
  --line: #d8ddd5;
  --line-strong: #bbc6bd;
  --accent: #1f6b3a;
  --accent-strong: #164d2c;
  --accent-soft: #e5f2e8;
  --blue: #28599a;
  --blue-soft: #eaf0fb;
  --amber: #936012;
  --amber-soft: #fff2d7;
  --red: #a73734;
  --red-soft: #fbe9e8;
  --gray-soft: #eef1ed;
  --shadow: 0 12px 30px rgba(24, 33, 27, 0.07);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

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

a:hover {
  color: #183f78;
}

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

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

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

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

h1,
h2,
h3,
p,
td,
th,
button,
textarea,
span {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 880px;
  font-size: clamp(1.25rem, 2.1vw, 1.78rem);
  line-height: 1.2;
  letter-spacing: 0;
}

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

h3 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  letter-spacing: 0;
}

.positioning {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

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

.scanner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  gap: 14px;
  min-height: min(672px, calc(100vh - 124px));
  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;
  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: 690;
  line-height: 1.2;
  text-align: center;
}

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

textarea {
  display: block;
  width: 100%;
  min-height: 286px;
  flex: 1 1 auto;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: none;
  background: #fbfcfa;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.48;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 58, 0.14);
}

textarea::placeholder {
  color: #7b8780;
}

.input-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 14px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.input-message {
  min-height: 21px;
  margin: 8px 0 0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

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

button {
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 120ms ease;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 3px solid rgba(31, 107, 58, 0.22);
  outline-offset: 2px;
}

.primary-action,
.secondary-action,
.ghost-action,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  white-space: nowrap;
  font-size: 0.82rem;
}

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

.primary-action:hover {
  background: var(--accent-strong);
}

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

.secondary-action:hover,
.ghost-action:hover,
.copy-button:hover {
  border-color: var(--accent);
}

.ghost-action {
  border-color: transparent;
  background: var(--gray-soft);
  color: #324038;
}

.button-glyph {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  line-height: 1;
}

.secondary-action .button-glyph,
.ghost-action .button-glyph,
.copy-button span:first-child {
  background: rgba(31, 107, 58, 0.1);
  color: var(--accent-strong);
}

.summary-heading {
  align-items: flex-start;
}

.status-critical {
  border-color: #e9b9b4;
  background: var(--red-soft);
  color: var(--red);
}

.status-warning {
  border-color: #ead19e;
  background: var(--amber-soft);
  color: var(--amber);
}

.status-review {
  border-color: #bccdeb;
  background: var(--blue-soft);
  color: var(--blue);
}

.status-ready {
  border-color: #b7d8c0;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

.score-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.78fr);
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-tint);
}

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

.score-band.state-warning {
  background: var(--amber-soft);
}

.score-band.state-review {
  background: var(--blue-soft);
}

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

.score-value {
  display: block;
  margin-top: 3px;
  font-size: clamp(1.45rem, 3vw, 2.45rem);
  line-height: 1.05;
}

.score-facts,
.metric-grid,
.score-facts div,
.metric-grid div {
  margin: 0;
}

.score-facts {
  display: grid;
  gap: 9px;
}

.score-facts dt,
.metric-grid dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

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

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

.metric-grid div,
.deadline-strip div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}

.metric-grid dd {
  font-size: 1.38rem;
  line-height: 1.05;
}

.deadline-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.deadline-strip span,
.next-action span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

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

.next-action {
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 5px;
  background: var(--surface-soft);
}

.risk-note {
  margin: auto 0 0;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.76rem;
}

.privacy-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.privacy-strip span {
  min-height: 36px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: #334139;
  font-size: 0.76rem;
  font-weight: 720;
}

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

.results-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

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

.tab-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 13px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: #344139;
  font-size: 0.78rem;
}

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

.tab-panel {
  padding: 18px;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

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

th {
  background: var(--surface-soft);
  color: #344139;
  font-size: 0.72rem;
  font-weight: 780;
}

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 730;
  white-space: nowrap;
}

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

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

.badge-ready {
  border-color: #b7d8c0;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge-review {
  border-color: #bccdeb;
  background: var(--blue-soft);
  color: var(--blue);
}

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

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

.work-section {
  padding: 14px;
}

.work-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.work-list li {
  padding: 10px;
  border-left: 4px solid var(--line-strong);
  border-radius: 4px;
  background: #ffffff;
  color: #2b3831;
  font-size: 0.82rem;
}

.work-list li.critical {
  border-left-color: var(--red);
}

.work-list li.warning {
  border-left-color: var(--amber);
}

.work-list li.ready {
  border-left-color: var(--accent);
}

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

.check-card {
  padding: 14px;
}

.check-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
}

.check-card strong {
  display: block;
  margin-top: 3px;
  font-size: 0.93rem;
}

.check-card p {
  margin: 8px 0 0;
  color: #47544c;
  font-size: 0.8rem;
}

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

.copy-card {
  padding: 12px;
  background: var(--surface-soft);
}

.copy-heading {
  align-items: center;
  margin-bottom: 8px;
}

.copy-button {
  min-height: 32px;
  padding: 6px 10px;
  border-color: var(--line-strong);
  background: #ffffff;
  color: #26342d;
  font-size: 0.74rem;
}

.copy-button span:first-child {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.copy-card textarea {
  min-height: 170px;
  resize: vertical;
  background: #ffffff;
}

.copy-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 1180px) {
  .scanner-grid {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .summary-panel {
    min-height: auto;
  }

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

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

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    gap: 9px;
  }

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

  .scanner-grid {
    padding-top: 10px;
  }

  .evidence-panel,
  .summary-panel,
  .tab-panel {
    padding: 14px;
  }

  textarea {
    min-height: 230px;
  }

  .score-band,
  .split-view,
  .copy-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .app-shell {
    width: calc(100% - 16px);
  }

  h1 {
    font-size: 1.22rem;
  }

  .panel-heading,
  .results-header,
  .work-heading,
  .copy-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .source-note {
    flex-flow: row wrap;
    gap: 3px 10px;
  }

  .source-note > span:not(.source-date) {
    display: none;
  }

  .action-row {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) minmax(116px, 1.45fr) minmax(64px, 0.8fr);
  }

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

  .privacy-strip,
  .checklist-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .tab-bar {
    padding-inline: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
