:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-alt: #eef3f1;
  --line: #d7ddd8;
  --line-strong: #b9c4bd;
  --text: #18221d;
  --muted: #607067;
  --primary: #116149;
  --primary-dark: #0b4736;
  --danger: #b3261e;
  --warning: #956200;
  --success: #1b6e3f;
  --focus: #3d7eff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 14px;
  line-height: 1.3;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.user-pill {
  background: var(--surface);
  color: var(--text);
}

.logout-form {
  margin: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;
  min-height: calc(100vh - 92px);
}

.workspace {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.toolbar,
.panel,
.result-band,
.email-section,
.side-panel {
  padding: 20px 28px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.tab {
  min-width: 84px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(28, 38, 32, 0.14);
}

.panel {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.active-panel {
  display: block;
}

.validation-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 112px;
  gap: 14px;
  align-items: end;
}

.batch-form {
  display: grid;
  gap: 12px;
}

.batch-actions {
  display: flex;
  justify-content: flex-end;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(61, 126, 255, 0.12);
}

.primary-btn,
.ghost-btn {
  min-height: 38px;
  border-radius: 6px;
  font-weight: 800;
}

.primary-btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.ghost-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.result-band {
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}

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

.status-strip > div {
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 14px;
  background: var(--surface);
}

.status-strip strong {
  overflow-wrap: anywhere;
  font-size: 18px;
}

.status-valid {
  color: var(--success);
}

.status-invalid {
  color: var(--danger);
}

.status-uncertain,
.status-error {
  color: var(--warning);
}

.status-affluent {
  color: var(--warning);
}

.status-not-affluent {
  color: var(--success);
}

.status-unclear {
  color: var(--muted);
}

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

.evidence-pane {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.evidence-pane p {
  color: var(--muted);
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.supporting-text {
  font-size: 13px;
}

.email-section {
  background: var(--surface);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title.compact {
  margin-top: 22px;
}

.side-panel {
  background: var(--surface);
  overflow: auto;
}

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

.metric {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 22px;
}

.audit-list {
  display: grid;
  gap: 8px;
}

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

.audit-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.audit-status {
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 800;
}

.audit-address {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.audit-meta {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--text);
  color: white;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 140ms ease, transform 140ms ease;
}

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

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(17, 97, 73, 0.08), rgba(17, 97, 73, 0)),
    var(--bg);
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  display: grid;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(24, 34, 29, 0.12);
}

.login-heading {
  display: grid;
  gap: 4px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(179, 38, 30, 0.28);
  border-radius: 6px;
  background: rgba(179, 38, 30, 0.08);
  color: var(--danger);
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .workspace {
    border-right: 0;
  }

  .validation-form,
  .status-strip,
  .evidence-grid {
    grid-template-columns: 1fr;
  }

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

  .header-meta {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .toolbar,
  .panel,
  .result-band,
  .email-section,
  .side-panel,
  .app-header {
    padding-left: 16px;
    padding-right: 16px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .tabs,
  .tab,
  .ghost-btn,
  .primary-btn {
    width: 100%;
  }
}
