:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #5f6b7a;
  --accent: #8f1d2c;
  --accent-dark: #65121d;
  --line: #d7dde5;
  --soft-line: #e8ebf0;
  --soft-fill: #f1f4f8;
  --success: #176b4d;
  --danger: #9f1f28;
  --shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  margin-bottom: 18px;
}

.hero-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.25;
}

.intro {
  max-width: 820px;
  color: var(--muted);
  font-size: 15px;
}

.auth-gate {
  max-width: 720px;
  margin: 48px auto 0;
  text-align: left;
}

.gate-actions,
.auth-actions,
.review-actions,
.admin-actions,
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-actions,
.admin-actions,
.review-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.signed-in-user {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.upload-form,
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.upload-label {
  display: block;
  width: 100%;
  font-weight: 700;
  font-size: 14px;
}

input[type="file"],
input[type="text"],
input[type="number"],
.table-input {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
}

input[type="file"] {
  flex: 1 1 300px;
  padding: 10px;
}

input[type="text"] {
  flex: 1 1 260px;
  padding: 10px 12px;
}

input[type="number"] {
  width: 76px;
  padding: 8px 10px;
}

.table-input {
  width: 100%;
  min-width: 130px;
  padding: 8px 10px;
}

button {
  min-height: 38px;
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.secondary-btn {
  background: white;
  color: var(--accent-dark);
  border: 1px solid #b9a2a7;
}

.danger-btn {
  color: var(--danger);
  border-color: #e2b8bd;
}

.table-action-btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.status {
  margin: 12px 2px 0;
  color: var(--accent-dark);
}

.error-text {
  color: var(--danger);
}

.muted,
.empty {
  color: var(--muted);
}

.loading {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--soft-fill);
  display: flex;
  gap: 12px;
  align-items: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(101, 18, 29, 0.18);
  border-top-color: var(--accent-dark);
  animation: spin 0.9s linear infinite;
}

.loading-text {
  margin: 0;
  color: var(--accent-dark);
  font-size: 14px;
}

.loading-copy {
  flex: 1;
  min-width: 0;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(101, 18, 29, 0.14);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.progress-detail {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.admin-jobs-scroll,
.editable-table-wrap {
  max-height: 460px;
  overflow: auto;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 42%);
  gap: 18px;
  align-items: start;
}

.review-main {
  min-width: 0;
}

.review-lists {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

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

.summary-grid dt {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid dd {
  margin: 4px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.item {
  padding-top: 12px;
  border-top: 1px solid var(--soft-line);
}

.item:first-child {
  padding-top: 0;
  border-top: 0;
}

.client-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.results-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.editable-results-table th:first-child,
.editable-results-table td:first-child {
  width: 120px;
}

.editable-results-table th:nth-child(2),
.editable-results-table td:nth-child(2) {
  width: 180px;
}

.editable-results-table th:nth-child(3),
.editable-results-table td:nth-child(3) {
  width: 210px;
}

.editable-results-table th:last-child,
.editable-results-table td:last-child,
.admin-jobs-table td:last-child,
.admin-jobs-table th:last-child {
  text-align: right;
}

.search-results {
  margin-top: 16px;
}

.search-result-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.pdf-review-panel {
  position: sticky;
  top: 18px;
  min-height: 720px;
}

.page-jump-form {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.page-jump-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.page-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.page-chip {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.page-chip.active-page {
  background: var(--accent-dark);
  color: white;
  border-color: var(--accent-dark);
}

.pdf-frame {
  width: 100%;
  height: 640px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-fill);
}

.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  text-decoration: underline;
  font: inherit;
  font-weight: 700;
}

.email-result {
  display: inline-block;
  margin-bottom: 3px;
}

.email-result.sent {
  color: var(--success);
}

.email-result.failed {
  color: var(--danger);
}

.hidden {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .review-layout,
  .review-lists {
    grid-template-columns: 1fr;
  }

  .pdf-review-panel {
    position: static;
    min-height: 0;
  }

  .pdf-frame {
    height: 560px;
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1040px);
    padding-top: 20px;
  }

  .hero-row,
  .panel-heading-row,
  .search-result-heading {
    flex-direction: column;
  }

  .auth-actions,
  .review-actions,
  .admin-actions,
  .page-jump-form {
    justify-content: flex-start;
  }

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

  .pdf-frame {
    height: 480px;
  }
}
