:root {
  color-scheme: light;
  --page: #f3f4ee;
  --surface: #ffffff;
  --surface-soft: #f8faf4;
  --surface-tint: #e7f3ef;
  --ink: #17201d;
  --muted: #5d6864;
  --line: #d8ddd4;
  --line-strong: #b9c4bd;
  --accent: #0f6b5f;
  --accent-strong: #084b43;
  --accent-soft: #dff0ec;
  --blue: #215b88;
  --blue-soft: #e6f0f8;
  --amber: #8b6216;
  --amber-soft: #fff0d3;
  --red: #ab3745;
  --red-soft: #fde8eb;
  --green: #1f6f3d;
  --green-soft: #e5f3e8;
  --gray-soft: #eef1ec;
  --shadow: 0 12px 30px rgba(23, 32, 29, 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 {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  overflow-x: hidden;
}

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: #173e66;
}

.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,
strong,
dd {
  overflow-wrap: anywhere;
  word-break: break-word;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-size: 1.68rem;
  line-height: 1.18;
  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 {
  max-width: 820px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.source-note {
  display: flex;
  flex: 0 1 520px;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  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(680px, 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 {
  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;
}

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

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

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

.status-unknown {
  background: var(--gray-soft);
}

.field-label {
  margin: 16px 0 7px;
  color: #34413d;
  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: #fbfcf9;
  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(15, 107, 95, 0.14);
}

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

.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 {
  cursor: pointer;
  border: 0;
  border-radius: 5px;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

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

button:focus-visible {
  outline: 3px solid rgba(15, 107, 95, 0.28);
  outline-offset: 2px;
}

.primary-action,
.secondary-action,
.ghost-action,
.copy-button,
.tab-button {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.15;
}

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

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

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

.secondary-action:hover {
  border-color: var(--accent);
}

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

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

.button-glyph {
  display: inline-flex;
  width: 16px;
  justify-content: center;
  margin-right: 4px;
  font-weight: 820;
}

.score-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--surface-soft), var(--surface-tint));
}

.score-band.state-high {
  background: linear-gradient(135deg, var(--red-soft), #fffaf7);
}

.score-band.state-medium {
  background: linear-gradient(135deg, var(--amber-soft), #fffdf7);
}

.score-band.state-low {
  background: linear-gradient(135deg, var(--green-soft), #fbfff8);
}

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

.score-value {
  display: block;
  margin-top: 4px;
  font-size: 2rem;
  line-height: 1.05;
}

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

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

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

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

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

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

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

.deadline-strip div {
  min-width: 0;
  padding: 10px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: #fbfcf9;
}

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

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

.next-action {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

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

.privacy-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 0 0 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcf9;
}

.privacy-strip span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 730;
}

.results-section {
  padding: 16px 0 0;
}

.results-header {
  padding: 0 2px 10px;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 12px;
  border-top: 1px solid var(--line);
}

.tab-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

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

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

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 820;
  overflow-wrap: normal;
  word-break: normal;
}

td {
  color: #2f3b37;
  font-size: 0.8rem;
}

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

.inventory-table th:nth-child(4),
.inventory-table td:nth-child(4) {
  overflow-wrap: normal;
  white-space: nowrap;
  word-break: normal;
}

.empty-row td,
.empty-row {
  color: var(--muted);
  font-weight: 680;
}

.muted-cell,
.muted-inline {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
}

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

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

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

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

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

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

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

.work-list li {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: #31403a;
  font-size: 0.8rem;
}

.work-list.compact li {
  padding: 7px 9px;
}

.copy-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
  align-items: start;
}

.copy-toolbar,
.redaction-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.copy-toolbar {
  display: grid;
  gap: 8px;
}

.copy-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-tint);
  color: var(--accent-strong);
}

.copy-button:hover:not(:disabled) {
  border-color: var(--accent);
}

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

.artifact-preview {
  min-height: 260px;
  margin: 14px 0 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101715;
  color: #e9f2ec;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100% - 36px));
  padding: 10px 12px;
  border: 1px solid rgba(15, 107, 95, 0.22);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 14px 32px rgba(23, 32, 29, 0.16);
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

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

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

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

@media (max-width: 720px) {
  .app-shell {
    width: calc(100vw - 20px);
    padding-top: 10px;
  }

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

  h1 {
    font-size: 1.28rem;
  }

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

  .evidence-panel,
  .summary-panel,
  .work-section,
  .copy-toolbar,
  .redaction-box {
    padding: 12px;
  }

  textarea {
    height: 176px;
    min-height: 160px;
    font-size: 0.82rem;
  }

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

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

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

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

  .primary-action,
  .secondary-action,
  .ghost-action,
  .tab-button {
    width: 100%;
    padding-inline: 8px;
  }

  table {
    min-width: 680px;
  }
}
