:root {
  color-scheme: light;
  --page: #f3f5f3;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --ink: #17201b;
  --muted: #5d6962;
  --line: #d8dfda;
  --line-strong: #bcc8c0;
  --green: #17643a;
  --green-soft: #e8f3ec;
  --blue: #2255a4;
  --blue-soft: #eaf0fb;
  --amber: #9a5a0a;
  --amber-soft: #fff3da;
  --red: #a12b2b;
  --red-soft: #fbeaea;
  --gray-soft: #eef1ef;
  --shadow: 0 10px 28px rgba(23, 32, 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: #173c77;
}

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

.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(--green);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(1.22rem, 2.2vw, 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 460px;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

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

.source-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.scanner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.07fr) minmax(420px, 0.93fr);
  gap: 14px;
  min-height: min(670px, calc(100vh - 125px));
  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 {
  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: 680;
  line-height: 1.2;
  text-align: center;
}

.field-label {
  margin: 16px 0 7px;
  color: #34413a;
  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: #fbfcfb;
  color: #1f2923;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.81rem;
  line-height: 1.48;
  tab-size: 2;
}

textarea::placeholder {
  color: #839088;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(34, 85, 164, 0.13);
}

.input-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.7rem;
}

.input-meta span:first-child {
  flex: none;
  font-variant-numeric: tabular-nums;
}

.input-meta span:last-child {
  max-width: 540px;
  text-align: right;
}

.input-message {
  min-height: 18px;
  margin: 3px 0 0;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 650;
}

.action-row,
.copy-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-row {
  margin-top: 8px;
}

.primary-action,
.secondary-action,
.ghost-action,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.79rem;
  font-weight: 720;
  line-height: 1.2;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary-action {
  min-width: 148px;
  background: var(--green);
  color: #ffffff;
}

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

.secondary-action {
  min-width: 108px;
  border-color: #aac2b2;
  background: var(--green-soft);
  color: #104d2d;
}

.secondary-action:hover {
  background: #dcece2;
}

.ghost-action {
  min-width: 96px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

.ghost-action:hover {
  border-color: var(--line-strong);
  background: var(--gray-soft);
  color: var(--ink);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(34, 85, 164, 0.25);
  outline-offset: 2px;
}

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

.button-icon {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

.status-chip {
  min-width: 92px;
  justify-content: center;
}

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

.status-high,
.status-deprecated {
  border-color: #ecd09e;
  background: var(--amber-soft);
  color: var(--amber);
}

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

.status-low,
.status-supported {
  border-color: #b7d9c3;
  background: var(--green-soft);
  color: var(--green);
}

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

.triage-band {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 5px;
  background: var(--surface-soft);
}

.triage-band.state-critical {
  border-left-color: var(--red);
  background: #fff9f9;
}

.triage-band.state-high {
  border-left-color: var(--amber);
  background: #fffbf3;
}

.triage-band.state-medium {
  border-left-color: var(--blue);
  background: #f8faff;
}

.triage-band.state-low {
  border-left-color: var(--green);
  background: #f7fcf8;
}

.triage-band.state-empty {
  border-left-color: #9aa59e;
}

.triage-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 680;
}

.triage-value {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.triage-facts {
  display: grid;
  grid-template-columns: 0.45fr 1.55fr;
  gap: 12px;
  margin: 0;
}

.triage-facts div {
  min-width: 0;
}

.triage-facts dt,
.metric-grid dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 680;
}

.triage-facts dd {
  margin: 3px 0 0;
  font-size: 0.78rem;
  font-weight: 680;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--line);
}

.metric-grid div {
  min-width: 0;
  padding: 10px;
  background: var(--surface);
}

.metric-grid dd {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.blocker-block {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.compact-list,
.work-list,
.plan-list {
  margin: 8px 0 0;
  padding-left: 19px;
}

.compact-list {
  display: grid;
  gap: 5px;
  font-size: 0.77rem;
}

.compact-list li::marker,
.work-list li::marker {
  color: var(--amber);
}

.next-action {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding: 12px 13px;
  border: 1px solid #bcd0ed;
  border-radius: 5px;
  background: var(--blue-soft);
}

.next-action span {
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 760;
  text-transform: uppercase;
}

.next-action strong {
  font-size: 0.79rem;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.risk-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.privacy-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.privacy-strip span {
  padding: 9px 12px;
  background: #f9fbfa;
  color: #46534c;
  font-size: 0.69rem;
  font-weight: 650;
  text-align: center;
}

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

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

.result-status {
  max-width: min(520px, 50%);
  border-radius: 5px;
  text-align: right;
}

.tab-bar {
  display: flex;
  align-items: stretch;
  min-height: 43px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.tab-button {
  position: relative;
  min-width: 108px;
  min-height: 43px;
  padding: 8px 16px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 720;
}

.tab-button:hover {
  background: var(--gray-soft);
  color: var(--ink);
}

.tab-button.is-active {
  background: var(--surface);
  color: var(--green);
}

.tab-button.is-active::after {
  position: absolute;
  right: 14px;
  bottom: -1px;
  left: 14px;
  height: 3px;
  background: var(--green);
  content: "";
}

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

.tab-panel[hidden] {
  display: none;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.timeline-item {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}

.timeline-item strong,
.timeline-item span,
.timeline-item small {
  display: block;
  overflow-wrap: anywhere;
}

.timeline-item strong {
  font-size: 0.8rem;
}

.timeline-item span {
  margin-top: 3px;
  font-size: 0.72rem;
  font-weight: 700;
}

.timeline-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.35;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  background: var(--surface-soft);
  color: #48544d;
  font-size: 0.68rem;
  font-weight: 760;
  text-transform: uppercase;
}

td {
  color: #28332d;
  font-size: 0.73rem;
  line-height: 1.42;
}

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

.inventory-table th:nth-child(1) { width: 15%; }
.inventory-table th:nth-child(2) { width: 9%; }
.inventory-table th:nth-child(3) { width: 14%; }
.inventory-table th:nth-child(4) { width: 13%; }
.inventory-table th:nth-child(5) { width: 10%; }
.inventory-table th:nth-child(6) { width: 15%; }
.inventory-table th:nth-child(7) { width: 13%; }
.inventory-table th:nth-child(8) { width: 11%; }

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

.cell-primary {
  display: block;
  color: var(--ink);
  font-weight: 720;
}

.cell-secondary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.67rem;
}

.table-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 730;
  line-height: 1.2;
}

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

.work-section {
  min-width: 0;
}

.work-section + .work-section {
  padding-left: 22px;
  border-left: 1px solid var(--line);
}

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

.work-heading span {
  max-width: 48%;
  min-height: 23px;
  border: 0;
  background: transparent;
  text-align: right;
}

.work-list,
.plan-list {
  display: grid;
  gap: 9px;
  padding-left: 21px;
  font-size: 0.77rem;
}

.work-list li,
.plan-list li {
  padding-left: 3px;
  overflow-wrap: anywhere;
}

.work-list strong,
.plan-list strong {
  color: var(--ink);
}

.plan-list li::marker {
  color: var(--green);
  font-weight: 760;
}

.plan-split {
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
}

.owner-table th:nth-child(1) { width: 18%; }
.owner-table th:nth-child(2) { width: 20%; }
.owner-table th:nth-child(3) { width: 17%; }
.owner-table th:nth-child(4) { width: 45%; }

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

.copy-toolbar {
  align-content: flex-start;
  flex-direction: column;
}

.copy-button {
  justify-content: flex-start;
  width: 100%;
  min-height: 43px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: #3f4d45;
  text-align: left;
}

.copy-button:hover:not(:disabled),
.copy-button.is-selected:not(:disabled) {
  border-color: #a8c1b0;
  background: var(--green-soft);
  color: #104d2d;
}

.artifact-preview {
  width: 100%;
  min-height: 360px;
  max-height: 570px;
  margin: 0;
  overflow: auto;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8faf8;
  color: #26312b;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.73rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  padding: 16px 2px 0;
  color: var(--muted);
  font-size: 0.69rem;
}

.app-footer p {
  max-width: 720px;
  margin: 0;
}

.app-footer p:last-child {
  text-align: right;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 13px;
  border: 1px solid #acc5b4;
  border-radius: 5px;
  background: #173f2a;
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(23, 32, 27, 0.2);
  font-size: 0.77rem;
  font-weight: 680;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
  overflow-wrap: anywhere;
}

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

@media (max-width: 1120px) {
  .scanner-grid {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  }

  .triage-band {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 22px, 720px);
    padding-top: 11px;
  }

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

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

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

  .scanner-grid {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

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

  textarea {
    min-height: 320px;
  }

  .next-action {
    margin-top: 14px;
  }

  .split-view,
  .plan-split,
  .copy-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .work-section + .work-section {
    padding-top: 18px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

  .app-footer {
    flex-direction: column;
    gap: 8px;
  }

  .app-footer p:last-child {
    text-align: left;
  }
}

@media (max-width: 720px) {
  .results-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .result-status {
    max-width: 100%;
    text-align: left;
  }

  .inventory-table,
  .owner-table,
  .inventory-table tbody,
  .owner-table tbody,
  .inventory-table tr,
  .owner-table tr,
  .inventory-table td,
  .owner-table td {
    display: block;
    width: 100%;
  }

  .inventory-table thead,
  .owner-table thead {
    display: none;
  }

  .inventory-table tr,
  .owner-table tr {
    padding: 4px 0;
    border-bottom: 1px solid var(--line);
  }

  .inventory-table tr:last-child,
  .owner-table tr:last-child {
    border-bottom: 0;
  }

  .inventory-table td,
  .owner-table td {
    display: grid;
    grid-template-columns: minmax(96px, 0.62fr) minmax(0, 1.38fr);
    gap: 10px;
    padding: 7px 10px;
    border-bottom: 0;
  }

  .inventory-table td::before,
  .owner-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 760;
    text-transform: uppercase;
  }

  .inventory-table .empty-row td,
  .owner-table .empty-row td {
    display: block;
    padding: 22px 12px;
  }

  .inventory-table .empty-row td::before,
  .owner-table .empty-row td::before {
    display: none;
  }
}

@media (max-width: 540px) {
  .app-shell {
    width: calc(100% - 14px);
    padding-bottom: 20px;
  }

  h1 {
    font-size: 1.2rem;
  }

  .panel-heading {
    gap: 9px;
  }

  .local-badge {
    flex: none;
  }

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

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

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

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

  .primary-action {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .triage-facts {
    grid-template-columns: 1fr;
  }

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

  .privacy-strip,
  .timeline-grid,
  .copy-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .privacy-strip span {
    text-align: left;
  }

  .tab-panel {
    padding: 13px 12px 15px;
  }

  .tab-button {
    min-width: 88px;
    padding: 8px 12px;
  }

  .work-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .work-heading span {
    max-width: 100%;
    padding: 0;
    text-align: left;
  }

  .artifact-preview {
    min-height: 300px;
  }
}

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