: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;
  --source-date: #2563eb;
  --source-vendor: #d97706;
  --source-amount: #16a34a;
  --source-tax: #7c3aed;
  --source-summary: #db2777;
}

* {
  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: 1440px;
  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.export-actions-top {
  padding-bottom: 12px;
  padding-top: 0;
}

.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-export-action,
.batch-extract-action {
  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,
.client-admin-table-wrap {
  overflow-x: auto;
}

.user-admin-table,
.client-admin-table {
  min-width: 880px;
}

.user-admin-table th,
.user-admin-table td,
.client-admin-table th,
.client-admin-table td {
  vertical-align: middle;
}

.user-admin-table .col-name,
.client-admin-table .col-name {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-admin-table .col-email {
  min-width: 16rem;
}

.user-admin-table .col-notes {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-admin-table .col-datetime,
.client-admin-table .col-datetime {
  white-space: nowrap;
}

.user-admin-table .col-actions,
.client-admin-table .col-actions {
  white-space: nowrap;
  width: 1%;
}

.row-actions {
  display: inline-block;
}

.row-actions-toggle {
  min-width: 4.5em;
}

.row-actions-menu {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(23, 32, 42, 0.14);
  display: grid;
  gap: 2px;
  min-width: 148px;
  padding: 6px;
  position: fixed;
  z-index: 40;
}

.row-actions-menu[hidden] {
  display: none;
}

.row-actions-item,
.row-actions-menu .row-actions-item {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: block;
  font: inherit;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

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

.row-actions-item.is-danger {
  color: var(--danger);
}

.row-actions-item:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.row-actions-menu form {
  margin: 0;
}

.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;
}

.list-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

.section-heading-text {
  display: grid;
  gap: 2px;
}

.section-heading-text h2 {
  margin: 0;
}

.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(auto-fit, 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 {
  --preview-rotation: 0deg;
  display: grid;
  gap: 8px;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  padding: 12px 18px 18px;
  position: relative;
}

.review-receipt-pane.has-companion-nav {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.receipt-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  justify-self: center;
  pointer-events: none;
  z-index: 20;
}

.receipt-preview-index {
  align-items: center;
  background: rgb(15 23 32 / 78%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  min-height: 36px;
  padding: 6px 14px;
}

.receipt-preview-toolbar-sep {
  align-self: stretch;
  background: rgb(255 255 255 / 28%);
  margin: 4px 2px;
  width: 1px;
}

.receipt-preview-tool {
  background: rgb(15 23 32 / 78%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  min-height: 36px;
  padding: 6px 14px;
  pointer-events: auto;
}

.receipt-preview-zoom-label {
  min-width: 4.5em;
}

.receipt-preview-tool:hover,
.receipt-preview-tool:focus-visible {
  background: rgb(15 23 32 / 92%);
  border-color: rgb(255 255 255 / 42%);
}

.receipt-preview-tool:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.receipt-preview-tool:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.receipt-preview-viewport {
  display: grid;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.receipt-preview-viewport > .receipt-preview-frame {
  margin: auto;
}

.receipt-preview-frame,
.pdf-preview-pages {
  position: relative;
  width: auto;
}

.pdf-preview-page {
  display: grid;
  margin: 0;
  min-height: 0;
}

.preview-page-nav {
  align-items: center;
  color: #fff;
  cursor: default;
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 800;
  gap: 12px;
  justify-content: center;
}

.preview-page-nav a {
  color: #d9e1e8;
  font-weight: 700;
  text-decoration: none;
}

.preview-page-nav a:hover,
.preview-page-nav a:focus-visible {
  color: #fff;
}

.preview-page-nav .is-disabled {
  color: rgb(255 255 255 / 35%);
}

.pdf-iframe-stage {
  min-height: 100%;
  min-width: 100%;
  position: relative;
}

.pdf-iframe-rotator {
  height: 100%;
  min-height: 0;
  width: 100%;
}

.receipt-preview-image {
  background: #fff;
  box-shadow: 0 14px 38px rgb(0 0 0 / 30%);
  display: block;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  max-width: 100%;
  object-fit: contain;
}

.receipt-preview-stage {
  display: grid;
  position: relative;
  width: max-content;
}

.receipt-preview-rotator {
  display: grid;
  position: relative;
  width: max-content;
}

.receipt-preview-stage.is-rotated {
  place-items: center;
}

.review-receipt-pane.is-preview-rotated [data-preview-rotator] {
  transform: rotate(var(--preview-rotation, 0deg));
  transform-origin: center center;
}

.receipt-source-overlay {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.receipt-source-box {
  /* マーカーのように枠の色で塗る。multiply で重ねるので下の印字は黒いまま読める（issue #224） */
  background: var(--source-color);
  border-radius: 2px;
  height: var(--source-height);
  left: var(--source-left);
  mix-blend-mode: multiply;
  opacity: 0.35;
  overflow: visible;
  position: absolute;
  top: var(--source-top);
  width: var(--source-width);
}

.receipt-source-box[data-source-box="transaction_date"] {
  --source-color: var(--source-date);
  z-index: 2;
}

.receipt-source-box[data-source-box="vendor"] {
  --source-color: var(--source-vendor);
  z-index: 1;
}

.receipt-source-box[data-source-box="amount"] {
  --source-color: var(--source-amount);
  z-index: 3;
}

.receipt-source-box[data-source-box="tax_rate"] {
  --source-color: var(--source-tax);
  z-index: 4;
}

.receipt-source-box[data-source-box="summary"] {
  --source-color: var(--source-summary);
  z-index: 5;
}

.review-receipt-pane iframe {
  background: #fff;
  border: 0;
  height: 100%;
  min-height: 0;
  width: 100%;
}

.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-client-return {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.review-client-identity {
  align-items: baseline;
  display: flex;
  gap: 6px;
  min-width: 0;
}

.review-client-identity code {
  color: var(--accent-dark);
  font-size: 12px;
}

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

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

.review-receipt-index {
  color: #0f1720;
}

.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-tax-breakdown {
  display: grid;
  gap: 4px;
}

.review-tax-breakdown table {
  font-size: 13px;
  margin-top: 0;
}

.review-tax-breakdown th,
.review-tax-breakdown td {
  overflow-wrap: anywhere;
  padding: 5px 6px;
  white-space: normal;
}

.review-tax-breakdown thead th,
.review-tax-breakdown td:first-child {
  white-space: nowrap;
}

.review-tax-breakdown tr.is-active td {
  background: var(--surface-strong);
  font-weight: 700;
}

.review-tax-breakdown .review-tax-breakdown-amount {
  text-align: right;
  white-space: nowrap;
}

.review-tax-breakdown tfoot tr.is-mismatch td {
  color: var(--danger);
  font-weight: 700;
}

.review-tax-breakdown small {
  color: var(--muted);
  font-size: 12px;
}

.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-compact-fields.has-source-highlights [data-source-field][data-has-source-box] > span::before {
  border-radius: 2px;
  content: "";
  display: inline-block;
  height: 0.7em;
  margin-right: 6px;
  vertical-align: 0.05em;
  width: 8px;
}

.review-compact-fields.has-source-highlights [data-source-field="transaction_date"][data-has-source-box] > span::before {
  background: var(--source-date);
}

.review-compact-fields.has-source-highlights [data-source-field="vendor"][data-has-source-box] > span::before {
  background: var(--source-vendor);
}

.review-compact-fields.has-source-highlights [data-source-field="amount"][data-has-source-box] > span::before {
  background: var(--source-amount);
}

.review-compact-fields.has-source-highlights [data-source-field="tax_rate"][data-has-source-box] > span::before {
  background: var(--source-tax);
}

.review-compact-fields.has-source-highlights [data-source-field="summary"][data-has-source-box] > span::before {
  background: var(--source-summary);
}

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

.review-source-toggle span {
  font-size: 13px;
  font-weight: 700;
}

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

.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;
}

/* 名前やメールなど長くなる列は折り返し、表が横にはみ出さないようにする（issue #211）。 */
td.wrap-cell {
  min-width: 8rem;
  overflow-wrap: anywhere;
  white-space: normal;
}

.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,
.pill.status-excluded {
  background: #f2f4f7;
  color: #475467;
}

.pill.status-unclear {
  background: #ffedd5;
  color: #9a3412;
}

tr.is-excluded,
tr.is-unclear {
  color: var(--muted);
}

.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;
}

.analysis-progress-bar.is-waiting span {
  animation: analysis-progress-waiting 1.8s ease-in-out infinite;
}

.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%);
  }
}

@keyframes analysis-progress-waiting {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.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;
}

/* 27インチ程度の広い画面では、チェック画面の入力欄を広げて文字を大きくする（issue #234）。
   領収書側の列は minmax(0, 1fr) のままなので、横スクロールは出ない。 */
@media (min-width: 1440px) {
  .review-workbench {
    grid-template-columns: minmax(0, 1fr) 520px;
  }

  .review-input-pane {
    font-size: 17px;
    gap: 12px;
    padding: 16px 20px;
  }

  .review-input-pane label > span,
  .review-progress,
  .review-row-heading span,
  .review-client-identity span {
    font-size: 15px;
  }

  .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: 42px;
    padding: 7px 10px;
  }

  .review-input-pane input[data-amount-input] {
    font-size: 20px;
    font-weight: 700;
  }

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

  .review-tax-breakdown table {
    font-size: 15px;
  }

  .review-tax-breakdown small {
    font-size: 13px;
  }
}

@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,
  .client-admin-table,
  .client-admin-table tbody,
  .client-admin-table tr,
  .client-admin-table td {
    display: block;
    width: 100%;
  }

  .user-admin-table,
  .client-admin-table {
    margin-top: 10px;
    min-width: 0;
  }

  .user-admin-table thead,
  .client-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,
  .client-admin-table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-top: 12px;
    padding: 6px 12px;
  }

  .user-admin-table td,
  .client-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);
    max-width: none;
    overflow: visible;
    padding: 10px 0;
    text-overflow: clip;
    white-space: normal;
  }

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

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

  .user-admin-table .col-email,
  .user-admin-table .col-name,
  .user-admin-table .col-notes,
  .client-admin-table .col-name {
    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;
  }
}
