:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #edf1f4;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee5;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #a16207;
  --danger: #b42318;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

.sr-only {
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  min-height: 64px;
  padding: 10px 28px;
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  min-width: 132px;
}

.top-nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 18px;
  min-width: 0;
}

.top-nav a,
.client-switch-link,
.logout-form button {
  color: var(--muted);
  font: inherit;
}

.top-nav .primary-link {
  color: var(--accent-dark);
  font-weight: 600;
}

.header-session-controls,
.logout-form,
.selected-client-control {
  align-items: center;
  display: flex;
}

.header-session-controls {
  flex: 0 1 auto;
  gap: 16px;
  margin-left: auto;
  min-width: 0;
}

.selected-client-control {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px;
}

.selected-client-label,
.client-choice-current {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.selected-client-identity {
  align-items: baseline;
  display: flex;
  gap: 6px;
  max-width: min(32vw, 360px);
  min-width: 0;
}

.selected-client-identity code {
  color: var(--accent-dark);
  flex: 0 0 auto;
  font-size: 12px;
}

.selected-client-identity span {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-switch-link {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.logout-form {
  gap: 12px;
}

.logout-form button {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.user-name {
  color: var(--text);
  font-weight: 600;
}

.page-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 32px 28px 56px;
}

.page-heading,
.section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.page-heading {
  margin-bottom: 24px;
}

.page-actions,
.table-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.section-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
}

.section-actions small {
  color: var(--muted);
}

.export-select-all {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}

.table-actions {
  flex-wrap: wrap;
}

.batch-operation-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.batch-operation-actions .compact-button {
  white-space: nowrap;
}

.page-actions form,
.table-actions form {
  margin: 0;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 19px;
}

p {
  color: var(--muted);
  margin: 4px 0 0;
}

.primary-button,
.secondary-button,
.danger-button {
  align-items: center;
  border-radius: var(--radius);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}

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

.danger-button {
  background: #fff;
  border: 1px solid #fecdca;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

button.primary-button,
button.secondary-button {
  cursor: pointer;
  font: inherit;
}

button.primary-button:disabled,
button.secondary-button:disabled,
button.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  margin-bottom: 28px;
}

.status-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.status-tile span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.status-tile strong {
  display: block;
  font-size: 28px;
  margin-top: 6px;
}

.flow-steps {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  padding: 12px;
}

.flow-step-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.flow-step {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  font-weight: 700;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
}

.flow-step-marker {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.flow-step-label {
  overflow-wrap: anywhere;
}

.flow-step.is-done {
  background: #ecfdf3;
  border-color: #abefc6;
  color: #067647;
}

.flow-step.is-active {
  background: #dff7f3;
  border-color: #99d8cf;
  color: #0f766e;
}

.flow-complete-badge {
  background: #dcfae6;
  border-radius: 999px;
  color: #067647;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
}

.empty-guide {
  align-items: center;
  display: grid;
  gap: 16px;
  justify-items: center;
  padding: 30px 18px;
  text-align: center;
}

.empty-guide p {
  margin: 0;
  max-width: 760px;
}

.empty-guide-action {
  min-height: 46px;
  padding-left: 20px;
  padding-right: 20px;
}

.empty-guide-compact {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  text-align: left;
}

.driver-popover.app-tour-popover {
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  max-width: min(360px, 90vw);
  min-width: min(270px, 90vw);
}

.driver-popover.app-tour-popover * {
  font-family: inherit;
}

.app-tour-popover .driver-popover-title {
  color: var(--text);
  font-size: 17px;
}

.app-tour-popover .driver-popover-description {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.app-tour-popover .driver-popover-footer button {
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
}

.section-block,
.auth-panel,
.upload-form,
.upload-dropzone {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.auth-panel {
  margin: 48px auto;
  max-width: 420px;
}

.client-selection-shell {
  max-width: 820px;
}

.client-selection-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.client-selection-heading {
  margin-bottom: 24px;
}

.client-selection-heading .eyebrow {
  color: var(--accent-dark);
  margin-bottom: 4px;
}

.client-selection-form {
  display: grid;
  gap: 20px;
}

.client-selection-search {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.client-selection-results {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin: 14px 0;
}

.client-selection-panel > .form-errors {
  margin-bottom: 18px;
}

.client-selection-panel > .form-errors p {
  color: var(--danger);
}

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

.client-choice {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  gap: 12px;
  min-width: 0;
  padding: 16px;
}

.client-choice:hover,
.client-choice:has(input:checked) {
  background: #f0fdfa;
  border-color: var(--accent);
}

.client-choice input {
  accent-color: var(--accent);
  flex: 0 0 auto;
  height: 18px;
  margin: 0;
  width: 18px;
}

.client-choice-details {
  display: grid;
  gap: 2px;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.client-choice-details code {
  color: var(--accent-dark);
  font-size: 13px;
}

.client-choice-current {
  margin-top: 3px;
}

.client-selection-no-results {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.client-selection-no-results p {
  margin-top: 4px;
}

.client-selection-form .primary-button {
  justify-self: end;
}

.client-selection-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 24px;
}

.client-selection-empty p {
  margin: 0;
}

.auth-help {
  margin: 8px 0 18px;
}

.google-oauth-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  display: flex;
  font-weight: 700;
  gap: 12px;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  text-decoration: none;
}

.google-oauth-button:hover {
  border-color: #b8c0cc;
  text-decoration: none;
}

.google-oauth-button span {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #4285f4;
  display: inline-flex;
  font-family: Arial, sans-serif;
  font-size: 16px;
  font-weight: 700;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.form-stack,
.upload-form {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  font-weight: 700;
}

.checkbox-field {
  align-items: flex-start;
  display: flex;
  gap: 10px;
}

.checkbox-field input[type="checkbox"] {
  flex: 0 0 auto;
  height: 18px;
  margin: 3px 0 0;
  width: 18px;
}

.checkbox-field small {
  display: block;
  font-weight: 400;
  margin-top: 3px;
}

.checkbox-field-compact {
  align-items: center;
  gap: 6px;
}

.checkbox-field-compact input[type="checkbox"] {
  margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
input[type="date"],
input[type="number"],
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

small {
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 10px;
}

.inline-form {
  margin: 0;
}

.user-admin-table-wrap {
  overflow-x: hidden;
}

.user-admin-table {
  table-layout: fixed;
}

.user-admin-table th,
.user-admin-table td {
  vertical-align: middle;
  white-space: nowrap;
}

.user-admin-table th:nth-child(1) {
  width: 18%;
}

.user-admin-table th:nth-child(2) {
  width: 12%;
}

.user-admin-table th:nth-child(3) {
  width: 9%;
}

.user-admin-table th:nth-child(4) {
  width: 13%;
}

.user-admin-table th:nth-child(5) {
  width: 19%;
}

.user-admin-table th:nth-child(6) {
  width: 12%;
}

.user-admin-table th:nth-child(7) {
  width: 17%;
}

.user-admin-actions {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.user-admin-actions .compact-button {
  white-space: nowrap;
}

.user-admin-email,
.user-admin-notes {
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-muted {
  color: var(--muted);
  font-size: 13px;
}

.danger-button-solid {
  background: #fee4e2;
}

.pagination {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 18px;
}

.pagination-status {
  color: var(--muted);
  font-weight: 700;
}

.disabled-button {
  opacity: 0.5;
  pointer-events: none;
}

.compact-button {
  min-height: 32px;
  padding: 5px 10px;
}

.client-list-header {
  align-items: end;
}

.client-filter-form {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 340px) 140px auto;
}

.client-code {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.94em;
}

.client-admin-actions {
  flex-wrap: wrap;
}

.client-admin-actions .compact-button {
  white-space: nowrap;
}

.narrow-form-panel {
  max-width: 720px;
}

.import-upload-panel {
  margin-bottom: 22px;
  max-width: 760px;
}

.format-callout {
  align-items: start;
  background: var(--surface-strong);
  border-radius: var(--radius);
  display: grid;
  gap: 6px;
  padding: 14px;
}

.format-callout code {
  overflow-wrap: anywhere;
}

.format-callout span,
.preview-note {
  color: var(--muted);
}

.import-error-panel {
  border-color: #fecdca;
  margin-bottom: 22px;
}

.import-error-panel h2,
.import-error-panel li {
  color: var(--danger);
}

.import-error-panel ul {
  margin-bottom: 0;
}

.import-summary-grid {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

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

.simple-list li {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 0;
}

.upload-dropzone {
  border: 2px dashed var(--line);
  display: grid;
  gap: 22px;
  margin-bottom: 22px;
  min-height: 260px;
  place-items: center;
  transition: border-color 120ms ease, background 120ms ease;
}

.upload-client-notice {
  align-items: center;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  color: #9a3412;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px 16px;
}

.upload-client-notice-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.upload-client-notice-copy strong {
  color: #7c2d12;
}

.upload-client-notice-copy p {
  color: inherit;
  margin: 0;
}

.upload-client-notice-copy small {
  color: #9a3412;
}

.upload-client-identity {
  color: var(--text);
  font-weight: 700;
}

.upload-client-identity code {
  margin-right: 3px;
  white-space: nowrap;
}

.upload-client-switch {
  flex: 0 0 auto;
  white-space: nowrap;
}

.upload-dropzone.is-dragging {
  background: #ecfdf3;
  border-color: var(--accent);
}

#folder-input {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.dropzone-main {
  align-items: center;
  display: grid;
  gap: 16px;
  justify-items: center;
}

.dropzone-main strong {
  font-size: 26px;
}

.upload-progress {
  display: grid;
  gap: 8px;
  max-width: 620px;
  width: 100%;
}

.progress-bar {
  background: var(--surface-strong);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-bar span {
  background: var(--accent);
  display: block;
  height: 100%;
  width: 0;
}

.progress-meta {
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.upload-log-panel {
  min-height: 148px;
}

.upload-log {
  color: var(--muted);
  margin: 14px 0 0;
  padding-left: 22px;
}

.upload-log li {
  padding: 4px 0;
}

.review-form {
  padding: 18px;
}

.review-table input,
.review-table select {
  min-width: 128px;
}

.review-table td:first-child {
  min-width: 220px;
  white-space: normal;
}

.review-shell {
  max-width: none;
  padding: 0;
}

.review-workbench {
  background: #20252b;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

.review-receipt-pane {
  align-items: center;
  cursor: zoom-in;
  display: grid;
  min-height: 0;
  overflow: hidden;
  padding: 18px;
  position: relative;
}

.review-receipt-pane.has-page-previews {
  align-items: center;
}

.receipt-preview-frame {
  display: grid;
  justify-self: center;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  max-width: 100%;
  position: relative;
}

.pdf-preview-pages {
  align-content: center;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  max-width: 100%;
  width: auto;
}

.pdf-preview-page {
  display: grid;
  gap: 8px;
  margin: 0;
  max-height: inherit;
  min-height: 0;
}

.pdf-preview-page figcaption {
  color: #d9e1e8;
  font-size: 13px;
  justify-self: center;
}

.pdf-preview-page.is-active figcaption {
  color: #fff;
  font-weight: 800;
}

.receipt-preview-image {
  background: #fff;
  box-shadow: 0 14px 38px rgb(0 0 0 / 30%);
  justify-self: center;
  max-height: inherit;
  max-width: 100%;
  object-fit: contain;
}

.pdf-preview-pages .receipt-preview-image {
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  width: auto;
}

.receipt-magnifier {
  background-color: #fff;
  background-repeat: no-repeat;
  border: 4px solid #fff;
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgb(0 0 0 / 36%);
  height: 300px;
  left: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  top: 0;
  transform: translate(-50%, -50%);
  transition: opacity 90ms ease;
  width: 300px;
  z-index: 30;
}

.receipt-preview-frame.is-lens-active .receipt-magnifier {
  opacity: 1;
}

.review-receipt-pane iframe {
  background: #fff;
  border: 0;
  height: 100%;
  transform-origin: var(--magnify-x, 50%) var(--magnify-y, 50%);
  transition: transform 80ms ease;
  width: 100%;
}

.review-receipt-pane.has-transform-magnifier iframe {
  pointer-events: none;
}

.review-receipt-pane.has-transform-magnifier.is-magnifying iframe {
  transform: scale(1.55);
}

.review-receipt-pane .secondary-button {
  justify-self: center;
}

.review-input-pane {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100vh;
  overflow-y: auto;
  padding: 14px 16px;
}

.review-input-pane label {
  gap: 4px;
}

.review-input-pane label > span {
  font-size: 13px;
}

.review-input-pane input[type="text"],
.review-input-pane input[type="date"],
.review-input-pane input[type="number"],
.review-input-pane select,
.review-input-pane textarea {
  min-height: 36px;
  padding: 6px 9px;
}

.review-input-pane textarea {
  height: 68px;
  min-height: 68px;
}

.review-progress {
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 700;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}

.review-reextract-action {
  display: flex;
  justify-content: flex-end;
}

.review-row-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding-bottom: 6px;
}

.review-row-heading span {
  color: var(--muted);
  font-size: 13px;
}

.review-compact-fields {
  display: grid;
  gap: 8px 10px;
  grid-template-columns: minmax(0, 2fr) minmax(110px, 1fr);
}

.review-field-wide {
  grid-column: 1 / -1;
}

.review-secondary-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.review-row-actions {
  display: flex;
  gap: 6px;
}

.review-row-actions .compact-button {
  font-size: 13px;
  min-height: 30px;
  padding: 4px 8px;
}

.review-check-toggle {
  align-items: center;
  display: flex;
  gap: 8px;
}

.review-check-toggle input {
  height: 18px;
  width: 18px;
}

.review-alert {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  color: #9a3412;
  display: grid;
  font-size: 13px;
  gap: 5px;
  padding: 10px;
}

.review-alert strong {
  color: #7c2d12;
}

.review-alert p {
  color: inherit;
  margin: 0;
}

.review-alert-list {
  display: grid;
  gap: 3px;
  margin: 0;
  padding-left: 20px;
}

.pill.review-attention-high {
  background: #fee2e2;
  color: #991b1b;
}

.pill.review-attention-medium {
  background: #fef3c7;
  color: #92400e;
}

.pill.review-attention-low {
  background: #dcfce7;
  color: #166534;
}

.review-pagination {
  background: var(--surface);
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  margin-top: auto;
  padding-top: 6px;
  position: sticky;
  bottom: 0;
}

.review-pagination .primary-button,
.review-pagination .secondary-button {
  align-items: center;
  font-size: 14px;
  min-height: 34px;
  min-width: 0;
  padding-bottom: 5px;
  padding-left: 8px;
  padding-right: 8px;
  padding-top: 5px;
  white-space: nowrap;
  width: 100%;
}

.review-workspace {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: 250px minmax(420px, 1fr) 360px;
  height: calc(100vh - 164px);
  min-height: 620px;
}

.review-file-rail,
.review-document-panel,
.review-editor-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.review-file-rail {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.review-rail-header,
.review-panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
}

.review-rail-header span,
.eyebrow,
.review-meta span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.review-rail-header strong {
  font-size: 14px;
}

.review-file-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

.review-file-item {
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  display: grid;
  gap: 6px;
  grid-template-columns: auto 1fr;
  padding: 10px;
  text-decoration: none;
}

.review-file-item:hover {
  background: var(--surface-strong);
  text-decoration: none;
}

.review-file-item.is-active {
  background: #eefbf8;
  border-color: #99d8cf;
}

.review-file-index {
  align-items: center;
  background: var(--surface-strong);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.review-file-name {
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.review-file-item .pill {
  grid-column: 2;
  justify-self: start;
}

.review-document-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.review-panel-header h2 {
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.document-preview {
  align-items: center;
  background: #20252b;
  display: grid;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.document-preview img {
  background: #fff;
  box-shadow: 0 12px 30px rgb(0 0 0 / 24%);
  justify-self: center;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.document-preview iframe {
  background: #fff;
  border: 0;
  height: 100%;
  min-height: 0;
  width: 100%;
}

.preview-fallback {
  justify-self: center;
}

.review-editor-panel {
  align-self: stretch;
  display: grid;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 16px;
}

.review-meta {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  padding: 0 16px;
}

.review-meta div {
  background: var(--surface-strong);
  border-radius: var(--radius);
  padding: 10px;
}

.review-meta strong {
  display: block;
  margin-top: 3px;
}

.review-field-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
  padding: 0 16px;
}

.wide-field {
  grid-column: 1 / -1;
}

.review-editor-actions {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 0 16px;
}

.review-editor-actions .primary-button,
.review-editor-actions .secondary-button {
  width: 100%;
}

.is-disabled {
  color: var(--muted);
  opacity: 0.55;
  pointer-events: none;
}

.disabled-link {
  color: var(--muted);
  font-weight: 700;
}

.form-errors,
.errorlist {
  color: var(--danger);
  margin: 0;
}

.messages {
  display: grid;
  gap: 10px;
  margin: 0;
  max-width: min(440px, calc(100vw - 32px));
  pointer-events: none;
  position: fixed;
  right: 16px;
  top: 16px;
  width: max-content;
  z-index: 100;
}

.message {
  align-items: start;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgb(16 24 40 / 18%);
  color: #067647;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  max-width: 100%;
  opacity: 1;
  padding: 10px 12px;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.message > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.message.is-dismissing {
  opacity: 0;
  transform: translateY(-6px);
}

.message-dismiss {
  background: transparent;
  border: 0;
  color: currentColor;
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  margin: -2px -2px -2px 0;
  opacity: 0.72;
  padding: 2px;
}

.message-dismiss:hover {
  opacity: 1;
}

.message.error {
  background: #fee4e2;
  border-color: #fecdca;
  color: var(--danger);
}

.message.warning {
  background: #fffaeb;
  border-color: #fedf89;
  color: var(--warn);
}

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

table {
  border-collapse: collapse;
  margin-top: 14px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pill {
  background: var(--surface-strong);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 9px;
}

.pill.status-approved,
.pill.status-checked,
.pill.status-exported,
.pill.is-checked {
  background: #dcfae6;
  color: #067647;
}

.pill.status-review,
.pill.status-needs_review,
.pill.status-confirmed,
.pill.status-extracted {
  background: #dff7f3;
  color: #107569;
}

.pill.status-uploaded,
.pill.status-draft {
  background: #fef3c7;
  color: #92400e;
}

.pill.status-analyzing {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.status-failed {
  background: #fee4e2;
  color: #b42318;
}

.pill.status-no_receipt {
  background: #f2f4f7;
  color: #475467;
}

.pill.status-needs_split,
.pill.is-warning {
  background: #ffedd5;
  color: #9a3412;
}

.document-status-note {
  color: var(--muted);
  display: block;
  margin-top: 6px;
  max-width: 320px;
  white-space: normal;
}

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

.document-details {
  padding: 0;
}

.section-block + .document-details {
  margin-top: 24px;
}

.document-details > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  list-style: none;
  padding: 18px 22px;
}

.document-details > summary::-webkit-details-marker {
  display: none;
}

.document-details > summary::after {
  color: var(--muted);
  content: "＋";
  font-size: 20px;
  font-weight: 700;
}

.document-details[open] > summary::after {
  content: "−";
}

.document-details > summary > span {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.document-details > summary > span:last-child {
  align-items: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.document-details > summary small {
  color: var(--muted);
  font-weight: 400;
}

.document-details[open] > summary {
  border-bottom: 1px solid var(--line);
}

.document-details .table-wrap {
  padding: 0 22px 22px;
}

.next-step-panel {
  align-items: center;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: var(--radius);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 16px;
}

.next-step-panel.is-action {
  background: #eefbf8;
  border-color: #99d8cf;
}

.next-step-panel.is-warning {
  background: #fff7ed;
  border-color: #fed7aa;
}

.next-step-copy {
  display: grid;
  gap: 4px;
}

.next-step-panel span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.next-step-panel strong {
  align-items: center;
  display: inline-flex;
  font-size: 18px;
  gap: 8px;
}

.next-step-panel p {
  color: var(--muted);
  margin: 0;
}

.next-step-action {
  align-items: flex-end;
  display: grid;
  gap: 10px;
  justify-items: end;
  min-width: 260px;
}

.next-step-action-inline {
  align-items: center;
  display: flex;
  justify-content: flex-end;
}

.analysis-spinner {
  animation: analysis-spin 0.85s linear infinite;
  border: 3px solid #99d8cf;
  border-top-color: #107569;
  border-radius: 50%;
  display: inline-block;
  height: 18px;
  width: 18px;
}

.analysis-progress {
  display: grid;
  gap: 6px;
  justify-items: end;
  max-width: 360px;
  width: 100%;
}

.analysis-progress-bar {
  background: #d9f0ec;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  width: 100%;
}

.analysis-progress-bar span {
  background: #107569;
  display: block;
  height: 100%;
  transition: width 0.2s ease;
}

.analysis-progress-bar.is-indeterminate span {
  animation: analysis-progress-indeterminate 1.4s ease-in-out infinite;
  width: 35% !important;
}

.batch-list-status {
  display: grid;
  gap: 8px;
  justify-items: start;
  min-width: 150px;
}

.batch-list-progress {
  color: var(--muted);
  display: grid;
  font-size: 11px;
  font-weight: 700;
  gap: 4px;
  max-width: 220px;
  width: 100%;
}

.batch-list-progress > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-row-new td {
  background: #ecfdf3;
  border-bottom-color: #84d8c9;
}

.batch-row-new td:first-child {
  box-shadow: inset 4px 0 #0f897d;
}

.batch-new-badge {
  background: #d1fadf;
  color: #067647;
  margin-left: 8px;
}

.analysis-progress-meta {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 2px;
  justify-items: end;
  max-width: 100%;
}

.analysis-progress-meta span {
  color: inherit;
  font-size: inherit;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: right;
  white-space: normal;
}

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

@keyframes analysis-progress-indeterminate {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(300%);
  }
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 24px;
}

.detail-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.detail-item span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.detail-item strong {
  display: block;
  margin-top: 6px;
}

.table-wrap small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
  max-width: 240px;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .app-header,
  .page-heading,
  .section-header,
  .page-actions,
  .flow-steps,
  .next-step-panel,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header {
    padding: 14px 18px;
  }

  .logout-form {
    margin-left: 0;
  }

  .header-session-controls {
    align-items: stretch;
    flex-direction: column;
    margin-left: 0;
    width: 100%;
  }

  .selected-client-control {
    border-radius: var(--radius);
    width: 100%;
  }

  .selected-client-identity {
    flex: 1 1 auto;
    max-width: none;
  }

  .logout-form {
    justify-content: space-between;
  }

  .next-step-action,
  .analysis-progress,
  .analysis-progress-meta {
    align-items: stretch;
    justify-items: stretch;
    min-width: 0;
  }

  .next-step-action-inline {
    flex-direction: column;
  }

  .flow-step-list {
    grid-template-columns: 1fr;
  }

  .empty-guide-compact {
    align-items: flex-start;
    flex-direction: column;
  }

  .upload-client-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-client-switch {
    width: 100%;
  }

  .client-filter-form,
  .import-summary-grid {
    grid-template-columns: 1fr;
  }

  .client-choice-list {
    grid-template-columns: 1fr;
  }

  .client-selection-search {
    grid-template-columns: 1fr;
  }

  .client-selection-panel {
    padding: 20px;
  }

  .client-selection-form .primary-button {
    justify-self: stretch;
    width: 100%;
  }

  .client-list-header {
    align-items: stretch;
  }

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

  .user-admin-table {
    margin-top: 10px;
  }

  .user-admin-table thead {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }

  .user-admin-table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-top: 12px;
    padding: 6px 12px;
  }

  .user-admin-table td {
    align-items: start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(110px, 36%) minmax(0, 1fr);
    padding: 10px 0;
    white-space: normal;
  }

  .user-admin-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 13px;
    font-weight: 700;
  }

  .user-admin-table td:last-child {
    border-bottom: 0;
  }

  .user-admin-actions {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .user-admin-email,
  .user-admin-notes {
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
  }

  .analysis-progress-meta span {
    text-align: left;
  }

  .page-shell {
    padding: 24px 18px 44px;
  }

}

@media (max-width: 1040px) {
  .review-workspace {
    grid-template-columns: 220px minmax(360px, 1fr);
  }

  .review-editor-panel {
    grid-column: 2;
  }
}

@media (max-width: 860px) {
  .review-workbench {
    grid-template-columns: 1fr;
    height: auto;
  }

  .review-receipt-pane {
    min-height: 60vh;
  }

  .review-input-pane {
    height: auto;
    min-height: 40vh;
  }

  .review-workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .review-editor-panel {
    grid-column: auto;
  }

  .review-file-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 72%);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .document-preview iframe {
    min-height: 520px;
  }
}
