:root {
  color-scheme: light;
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-soft: #f1f6f4;
  --text: #202826;
  --muted: #65736f;
  --line: #d9e3df;
  --line-strong: #b8cbc5;
  --teal: #1f6f68;
  --teal-dark: #15534e;
  --amber: #d98f21;
  --red: #b64b3c;
  --shadow: 0 18px 60px rgba(32, 40, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1560px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand,
.topbar-actions,
.panel-heading,
.evidence-row,
.stage-item,
.verdict-grid {
  display: flex;
  align-items: center;
}

.brand {
  gap: 13px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p,
.panel-heading p,
.topbar-actions,
.label,
.copy-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.topbar-actions {
  gap: 11px;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
}

.ghost-link {
  color: var(--teal-dark);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(330px, 1.08fr) minmax(360px, 1.12fr) minmax(330px, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}

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

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  margin-bottom: 14px;
}

.primary-button,
.icon-button {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  min-height: 36px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.primary-button {
  background: var(--teal);
  color: #fff;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 750;
}

.icon-button {
  width: 36px;
  background: var(--surface);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

.primary-button:hover,
.icon-button:hover,
.sample-card:hover,
.ghost-link:hover {
  transform: translateY(-1px);
  border-color: var(--teal);
}

.sample-list {
  display: grid;
  gap: 10px;
}

.sample-card {
  width: 100%;
  min-height: 96px;
  display: grid;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.sample-card.selected {
  border-color: var(--teal);
  background: var(--surface-soft);
}

.sample-card span,
.sample-card strong,
.sample-card small {
  overflow-wrap: anywhere;
}

.sample-card span {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
}

.sample-card strong,
.sample-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.email-panel,
.extraction-panel,
.payload-panel {
  display: flex;
  flex-direction: column;
}

.evidence-row {
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.evidence-preview {
  width: 116px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #e9f3f0;
  flex: 0 0 auto;
}

.email-summary {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.email-summary strong {
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.label {
  display: block;
  font-weight: 750;
  text-transform: uppercase;
}

.email-body,
.payload-code {
  margin: 14px 0 0;
  white-space: pre-wrap;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfc;
  color: #26302d;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.email-body {
  min-height: 398px;
  max-height: 55vh;
  padding: 14px;
}

.score-chip {
  min-width: 60px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--amber);
  font-size: 13px;
  font-weight: 850;
}

.score-chip[data-level="high"] {
  background: var(--teal);
}

.stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.stage-item {
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.stage-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
  flex: 0 0 auto;
}

.stage-item.needs-review .stage-marker {
  background: var(--amber);
}

.stage-item.blocked .stage-marker {
  background: var(--red);
}

.stage-item strong,
.stage-item small {
  display: block;
  line-height: 1.25;
}

.stage-item strong {
  font-size: 13px;
}

.stage-item small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 800;
}

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

.verdict-grid {
  align-items: stretch;
  gap: 9px;
}

.verdict-grid > div {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.verdict-grid strong {
  min-height: 34px;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.payload-code {
  flex: 1 1 auto;
  min-height: 490px;
  max-height: 62vh;
  padding: 14px;
}

.copy-status {
  min-height: 18px;
  margin-top: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1260px) {
  .workspace {
    grid-template-columns: minmax(220px, 0.75fr) minmax(360px, 1.25fr);
  }

  .payload-panel {
    grid-column: span 2;
  }
}

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

  .topbar,
  .workspace,
  .evidence-row,
  .verdict-grid {
    display: grid;
  }

  .topbar {
    justify-content: stretch;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .payload-panel {
    grid-column: auto;
  }

  .panel {
    padding: 14px;
  }

  .panel-heading {
    align-items: start;
  }

  .email-body,
  .payload-code {
    max-height: none;
  }
}
