:root {
  color-scheme: light;
  --page: #f3f5f3;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --ink: #18211c;
  --muted: #5c6860;
  --line: #d7ded8;
  --line-strong: #b8c5bc;
  --green: #17643a;
  --green-soft: #e6f3eb;
  --blue: #255aa2;
  --blue-soft: #e9f0fb;
  --amber: #9a5a0a;
  --amber-soft: #fff3da;
  --red: #a32929;
  --red-soft: #fbe9e9;
  --gray-soft: #eef1ef;
  --shadow: 0 10px 28px rgba(24, 33, 28, 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: #183f75;
}

.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,
td,
th,
li,
dd,
dt {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 920px;
  font-size: clamp(1.18rem, 2vw, 1.72rem);
  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: 720;
}

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

.scanner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  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: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.83rem;
  line-height: 1.48;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 90, 162, 0.13);
}

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

.input-message {
  min-height: 20px;
  margin: 5px 0 0;
  color: var(--red);
  font-size: 0.74rem;
  font-weight: 680;
}

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

.primary-action,
.secondary-action,
.ghost-action,
.copy-button,
.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 740;
  letter-spacing: 0;
  line-height: 1.15;
  white-space: nowrap;
}

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

.secondary-action {
  border-color: #b5c8ba;
  background: var(--green-soft);
  color: #17472b;
}

.ghost-action {
  border-color: var(--line);
  background: var(--surface-soft);
  color: #2f3a34;
}

.primary-action:hover,
.secondary-action:hover,
.ghost-action:hover,
.copy-button:hover,
.tab-button:hover {
  filter: brightness(0.98);
}

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

.summary-panel {
  gap: 14px;
}

.triage-band {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(260px, 1.18fr);
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

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

.state-high {
  border-left-color: #c45424;
  background: #fff0e7;
}

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

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

.state-empty {
  border-left-color: var(--line-strong);
}

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

.triage-value {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
  line-height: 1.15;
}

.triage-facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

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

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 720;
}

dd {
  margin: 2px 0 0;
  font-size: 0.85rem;
  font-weight: 720;
}

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

.metric-grid div {
  min-height: 68px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}

.metric-grid dd {
  font-size: 1.25rem;
}

.blocker-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.compact-list,
.work-list {
  display: grid;
  gap: 7px;
  margin: 9px 0 0;
  padding-left: 18px;
  color: #334039;
  font-size: 0.82rem;
}

.next-action {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid #cdd7ce;
  border-radius: 5px;
  background: #f6fbf7;
}

.next-action span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 740;
  text-transform: uppercase;
}

.next-action strong {
  font-size: 0.86rem;
  line-height: 1.35;
}

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

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

.status-high,
.chip-high {
  border-color: #f0c8b4;
  background: #fff0e7;
  color: #b24316;
}

.status-medium,
.chip-medium,
.chip-needs-owner {
  border-color: #ebd49b;
  background: var(--amber-soft);
  color: var(--amber);
}

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

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

.chip-al2 {
  border-color: #e0b1b1;
  background: var(--red-soft);
  color: var(--red);
}

.privacy-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.privacy-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: #34413a;
  font-size: 0.76rem;
  font-weight: 700;
}

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

.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 15px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.tab-button {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab-button.is-active {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(24, 33, 28, 0.06);
}

.tab-panel {
  min-width: 0;
}

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

.timeline-item {
  min-height: 114px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.84rem;
}

.timeline-item span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.timeline-item a {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.74rem;
}

.portfolio-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #bfd0d8;
  border-radius: 5px;
  background: #eef6f9;
  color: #273840;
  font-size: 0.82rem;
}

.portfolio-summary span {
  color: #45545b;
  text-align: right;
}

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

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

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

.inventory-table th {
  background: var(--surface-soft);
  color: #34413a;
  font-size: 0.72rem;
  font-weight: 780;
  text-transform: uppercase;
}

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

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.status-mini {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 23px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
  line-height: 1.15;
}

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

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

.plan-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 0.82rem;
}

.owner-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 10px;
}

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

.owner-item strong {
  display: block;
  font-size: 0.82rem;
}

.owner-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

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

.copy-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}

.copy-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.copy-button {
  min-width: 80px;
  min-height: 38px;
  border-color: #b7c9d9;
  background: var(--blue-soft);
  color: var(--blue);
}

.copy-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

@media (max-width: 1080px) {
  .scanner-grid,
  .split-view,
  .copy-grid {
    grid-template-columns: 1fr;
  }

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

  .summary-panel {
    order: 2;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 1480px);
    padding-top: 12px;
  }

  .app-header {
    display: block;
    min-height: 0;
  }

  .source-note {
    align-items: flex-start;
    margin-top: 12px;
    text-align: left;
  }

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

  .evidence-panel,
  .summary-panel,
  .results-section {
    padding: 13px;
  }

  textarea {
    min-height: 254px;
    font-size: 0.78rem;
  }

  .input-meta {
    display: grid;
  }

  .action-row,
  .metric-grid,
  .tab-bar,
  .timeline-grid,
  .owner-grid {
    grid-template-columns: 1fr;
  }

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

  .portfolio-summary {
    display: grid;
  }

  .portfolio-summary span {
    text-align: left;
  }

  .inventory-table {
    min-width: 0;
    border: 0;
  }

  .inventory-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

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

  .inventory-table tr {
    border-bottom: 1px solid var(--line);
  }

  .inventory-table td {
    display: grid;
    grid-template-columns: minmax(104px, 34%) minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 8px 10px;
  }

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

  .empty-row td {
    display: block;
    text-align: left;
  }

  .empty-row td::before {
    content: "";
    display: none;
  }
}
