:root {
  color-scheme: light;
  --background: #f8f8fa;
  --panel: #ffffff;
  --foreground: #1a1a2e;
  --muted: #676775;
  --line: #cad0d0;
  --line-soft: #e6e8e8;
  --primary: #817aa6;
  --primary-dark: #6d668f;
  --primary-soft: #f0eef7;
  --success: #34785d;
  --success-dark: #286248;
  --danger: #b94a50;
  --danger-dark: #9e3b42;
  --warning: #a36a25;
  --warning-dark: #89571d;
  --shadow: 0 1px 3px rgb(26 26 46 / 8%);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

/* Anzen本番環境の色と密度を基準にした共通レイアウト。 */
* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  background: var(--background);
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  margin: 0;
  min-height: 100vh;
}

a {
  color: var(--primary-dark);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  align-items: center;
  background: var(--primary);
  border-bottom: 1px solid rgb(255 255 255 / 18%);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  color: #ffffff;
  display: flex;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-logo {
  border-radius: 8px;
  display: block;
  flex: 0 0 32px;
  height: 32px;
  object-fit: cover;
  width: 32px;
}

.brand-divider {
  background: rgb(255 255 255 / 32%);
  height: 24px;
  width: 1px;
}

.brand strong {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-tools,
.header-account,
.header-user {
  align-items: center;
  display: flex;
}

.header-tools {
  gap: 14px;
}

.header-account {
  gap: 12px;
}

.header-user {
  flex-direction: column;
  line-height: 1.2;
}

.header-user span {
  color: rgb(255 255 255 / 74%);
  font-size: 10px;
}

.header-user strong {
  font-size: 12px;
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-switch {
  align-items: center;
  border: 1px solid rgb(255 255 255 / 38%);
  border-radius: 6px;
  display: flex;
  height: 30px;
  overflow: hidden;
}

.language-switch a {
  align-items: center;
  color: #ffffff;
  display: inline-flex;
  font-size: 11px;
  height: 100%;
  padding: 0 9px;
  text-decoration: none;
  white-space: nowrap;
}

.language-switch a + a {
  border-left: 1px solid rgb(255 255 255 / 38%);
}

.language-switch a[aria-current="page"] {
  background: #ffffff;
  color: var(--primary-dark);
  font-weight: 700;
}

.header-button {
  background: transparent;
  border: 1px solid rgb(255 255 255 / 38%);
  border-radius: 6px;
  color: #ffffff;
  min-height: 30px;
  padding: 4px 10px;
}

.header-button:hover,
.header-button:focus-visible {
  background: rgb(255 255 255 / 12%);
}

.page-shell {
  flex: 1;
  margin: 0 auto;
  max-width: 1440px;
  padding: 28px 24px 48px;
  width: 100%;
}

.site-footer {
  color: var(--muted);
  font-size: 11px;
  padding: 12px 16px 18px;
  text-align: center;
}

.page-heading {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-heading h1 {
  font-size: 28px;
  line-height: 1.3;
  margin: 3px 0 6px;
}

.page-heading p {
  color: var(--muted);
  margin: 0;
}

.eyebrow {
  color: var(--primary-dark) !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.sync-control {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sync-control span {
  color: var(--muted);
  font-size: 12px;
  max-width: 340px;
  text-align: right;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.export-icon {
  font-size: 16px;
  line-height: 1;
  margin-right: 6px;
}

.breadcrumb {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  margin-bottom: 18px;
}

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

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.stat-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.stat-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.25;
  margin-top: 5px;
}

.stat-card .status-text {
  font-size: 16px;
  min-height: 30px;
}

.panel-toolbar,
.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.panel-toolbar {
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
  gap: 16px;
  padding: 12px 14px;
}

.search-field {
  width: min(520px, 70%);
}

input,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--foreground);
  min-height: 40px;
  padding: 8px 11px;
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: #8a8a96;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(129 122 166 / 18%);
  outline: none;
}

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

.data-table {
  border-collapse: collapse;
  min-width: 1240px;
  width: 100%;
}

.data-table th {
  background: #f3f3f6;
  color: #565665;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: left;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 13px;
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: #faf9fc;
}

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

.data-table td {
  font-size: 13px;
}

.data-table td small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.amount-cell {
  font-size: 15px !important;
  font-weight: 700;
  white-space: nowrap;
}

.list-gallery {
  display: flex;
  gap: 5px;
  min-width: 132px;
}

.list-image-button,
.file-chip {
  background: #f3f3f6;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  height: 48px;
  overflow: hidden;
  padding: 0;
  width: 48px;
}

.image-icon {
  display: block;
  height: 46px;
  object-fit: cover;
  transition: transform 160ms ease;
  width: 46px;
}

.list-image-button:hover .image-icon {
  transform: scale(1.04);
}

.file-chip {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 9px;
  font-weight: 700;
  justify-content: center;
  text-decoration: none;
}

.list-gallery + small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 220px;
}

.list-actions .button {
  font-size: 11px;
  min-height: 32px;
  padding: 5px 8px;
}

/* AI結果は一覧で要点を確認でき、詳細だけを展開表示する。 */
.ai-review-cell {
  max-width: 360px;
  min-width: 290px;
}

.ai-review-button {
  font-size: 11px;
  min-height: 32px;
  padding: 5px 9px;
}

.ai-review-cell > small,
.ai-review-result > small {
  color: var(--muted);
  display: block;
  margin-top: 5px;
}

.ai-review-state,
.ai-recommendation {
  border: 1px solid var(--line);
  border-radius: 4px;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
}

.ai-review-state {
  background: #f3f3f6;
  color: var(--foreground);
}

.ai-review-state-warning,
.ai-recommendation-review_needed,
.ai-recommendation-additional_documents {
  background: #fff7e8;
  border-color: #e3c78e;
  color: #76501f;
}

.ai-recommendation-approve_candidate {
  background: #eaf5ef;
  border-color: #a9cfbc;
  color: var(--success-dark);
}

.ai-recommendation-unable_to_assess {
  background: #f1f2f4;
  color: #575b63;
}

.ai-review-result p {
  line-height: 1.45;
  margin: 7px 0;
}

.ai-review-details {
  border-top: 1px solid var(--line-soft);
  margin: 8px 0;
  padding-top: 6px;
}

.ai-review-details summary {
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.ai-review-checks,
.ai-review-documents {
  margin: 7px 0;
  padding-left: 18px;
}

.ai-review-checks li,
.ai-review-documents li {
  margin: 5px 0;
}

.ai-review-checks strong,
.ai-review-checks span {
  display: block;
}

.ai-review-checks span {
  color: var(--muted);
  font-size: 11px;
}

.ai-documents-heading {
  display: block;
  font-size: 11px;
  margin-top: 9px;
}

.ai-review-advisory {
  border-left: 2px solid var(--line);
  font-size: 10px;
  line-height: 1.4;
  padding-left: 6px;
}

.muted-cell {
  color: var(--muted);
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 7px 13px;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button:focus-visible,
.icon-button:focus-visible,
.language-switch a:focus-visible {
  outline: 3px solid rgb(255 255 255 / 55%);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-primary {
  background: var(--primary);
  color: #ffffff;
}

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

.button-secondary {
  background: #f3f3f6;
  border-color: var(--line);
  color: var(--foreground);
}

.button-secondary:hover {
  background: #e9e9ee;
}

.button-approve {
  background: var(--success);
  color: #ffffff;
}

.button-approve:hover {
  background: var(--success-dark);
}

.button-reject {
  background: var(--danger);
  color: #ffffff;
}

.button-reject:hover {
  background: var(--danger-dark);
}

.button-warning {
  background: var(--warning);
  color: #ffffff;
}

.button-warning:hover {
  background: var(--warning-dark);
}

.status-pill {
  background: var(--primary-soft);
  border: 1px solid #d5d1e5;
  border-radius: 999px;
  color: var(--primary-dark);
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  white-space: nowrap;
}

.status-large {
  font-size: 12px;
  margin-top: 7px;
  padding: 5px 10px;
}

.detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.3fr 1fr;
  margin-bottom: 24px;
}

.summary-card,
.action-card,
.raw-data {
  padding: 18px;
}

.summary-card h2,
.action-card h2,
.section-block h2 {
  font-size: 18px;
  margin-top: 0;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.summary-list div {
  display: grid;
  font-size: 13px;
  grid-template-columns: 130px 1fr;
}

dt {
  color: var(--muted);
  font-weight: 600;
}

dd {
  margin: 0;
  white-space: pre-wrap;
}

.action-card > p {
  color: var(--muted);
  font-size: 13px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.callout,
.danger-notice {
  background: #fff9ed;
  border: 1px solid #ead6aa;
  border-radius: 6px;
  color: #664b20 !important;
  padding: 10px 11px;
}

/* 詳細セクションはカード内カードにせず、情報帯として区切る。 */
.section-block.panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  margin-top: 30px;
  padding: 0;
}

.section-heading {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding: 0 0 9px;
}

.section-heading h2 {
  margin: 2px 0 0;
}

.section-heading > span {
  color: var(--muted);
  font-size: 12px;
  max-width: 55%;
  text-align: right;
}

.gallery {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.attachment-card {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.attachment-card > div {
  padding: 10px 12px;
}

.attachment-card small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.image-button {
  background: #f3f3f6;
  border: 0;
  display: block;
  height: 220px;
  overflow: hidden;
  padding: 0;
  width: 100%;
}

.image-button img {
  height: 100%;
  object-fit: contain;
  transition: transform 180ms ease;
  width: 100%;
}

.image-button:hover img {
  transform: scale(1.02);
}

.file-placeholder {
  align-items: center;
  background: #f3f3f6;
  color: var(--muted);
  display: flex;
  font-size: 20px;
  font-weight: 700;
  height: 220px;
  justify-content: center;
}

.checksum {
  font-size: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-grid {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
}

.field-grid div {
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  font-size: 13px;
  gap: 12px;
  grid-template-columns: minmax(140px, 0.75fr) 1.25fr;
  padding: 10px 12px;
}

.field-grid div:nth-child(odd) {
  border-right: 1px solid var(--line-soft);
}

.route-list {
  display: grid;
  gap: 7px;
}

.route-step {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  display: grid;
  font-size: 12px;
  gap: 10px;
  grid-template-columns: 48px repeat(4, 1fr);
  padding: 9px 11px;
}

.raw-data {
  margin-top: 30px;
}

.raw-data summary {
  cursor: pointer;
  font-weight: 700;
}

pre {
  background: #22222f;
  border-radius: 6px;
  color: #f2f2f5;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.modal {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgb(26 26 46 / 28%);
  color: var(--foreground);
  max-width: 620px;
  padding: 0;
  width: calc(100% - 32px);
}

.modal::backdrop,
.image-modal::backdrop {
  background: rgb(26 26 46 / 64%);
}

.modal form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.modal label {
  display: grid;
  font-size: 13px;
  font-weight: 600;
  gap: 6px;
}

.modal-heading,
.modal-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.modal-heading h2 {
  font-size: 20px;
  margin: 2px 0 0;
}

.modal-actions {
  gap: 8px;
  justify-content: flex-end;
}

.icon-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  padding: 4px;
}

.form-note {
  color: var(--muted);
  font-size: 12px;
  margin: -4px 0 0;
}

.form-status {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  min-height: 20px;
  text-align: center;
}

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

/* ログイン画面は説明カードを置かず、認証操作だけを中央に配置する。 */
.login-page .page-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  padding-bottom: 48px;
  padding-top: 48px;
}

.login-layout {
  width: min(100%, 360px);
}

.login-card {
  width: 100%;
}

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

.login-card h1 {
  font-size: 24px;
  margin: 0 0 4px;
  text-align: center;
}

.login-card label {
  display: grid;
  font-size: 13px;
  font-weight: 600;
  gap: 6px;
}

.login-card .button {
  margin-top: 2px;
  width: 100%;
}

.image-modal {
  background: #22222f;
  border: 0;
  border-radius: 8px;
  max-height: 94vh;
  max-width: 94vw;
  padding: 14px;
  position: relative;
  width: min(94vw, 1200px);
}

.image-modal img {
  display: block;
  margin: 0 auto;
  max-height: 82vh;
  max-width: 88vw;
  object-fit: contain;
}

.image-modal-meta {
  align-items: baseline;
  color: #ffffff;
  display: flex;
  gap: 10px;
  justify-content: center;
  min-height: 24px;
  text-align: center;
}

.image-modal-meta p {
  margin: 8px 0 0;
}

.image-modal-meta span {
  color: rgb(255 255 255 / 72%);
  font-size: 12px;
  white-space: nowrap;
}

/* 画像上に重ね、画面幅を変えても移動位置を固定する。 */
.image-nav {
  align-items: center;
  background: rgb(0 0 0 / 58%);
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 50%;
  color: #ffffff;
  display: inline-flex;
  font-size: 24px;
  height: 44px;
  justify-content: center;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  z-index: 1;
}

/* 画像が1枚だけの場合はナビゲーションを表示しない。 */
.image-nav[hidden] {
  display: none;
}

.image-previous {
  left: 18px;
}

.image-next {
  right: 18px;
}

.image-close {
  align-items: center;
  background: rgb(0 0 0 / 58%);
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 50%;
  color: #ffffff;
  display: inline-flex;
  font-size: 28px;
  height: 40px;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 9px;
  top: 9px;
  width: 40px;
  z-index: 1;
}

.toast {
  background: var(--foreground);
  border-radius: 6px;
  bottom: 20px;
  color: #ffffff;
  font-size: 13px;
  max-width: min(520px, calc(100vw - 32px));
  opacity: 0;
  padding: 11px 14px;
  pointer-events: none;
  position: fixed;
  right: 20px;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

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

.toast-error {
  background: var(--danger);
}

.empty-state {
  color: var(--muted);
  padding: 28px !important;
  text-align: center;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

/* 狭い画面では操作順を保ちながら一列表示へ切り替える。 */
@media (max-width: 850px) {
  .stats-grid,
  .detail-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .sync-control {
    align-items: stretch;
  }

  .sync-control span {
    max-width: none;
    text-align: left;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .summary-list div,
  .field-grid div {
    grid-template-columns: 1fr;
  }

  .field-grid div:nth-child(odd) {
    border-right: 0;
  }

  .route-step {
    grid-template-columns: 42px 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    gap: 8px;
    padding: 0 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand strong,
  .brand-divider,
  .header-user {
    display: none;
  }

  .header-tools,
  .header-account {
    gap: 7px;
  }

  .language-switch a {
    padding: 0 7px;
  }

  .header-button {
    padding: 4px 8px;
  }

  .page-shell {
    padding: 22px 14px 38px;
  }

  .page-heading h1 {
    font-size: 23px;
  }

  .panel-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field {
    width: 100%;
  }

  .section-heading {
    align-items: flex-start;
    gap: 8px;
  }

  .section-heading > span {
    max-width: 42%;
  }

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

  .login-page .page-shell {
    padding-left: 24px;
    padding-right: 24px;
  }

  .toast {
    bottom: 14px;
    left: 16px;
    right: 16px;
  }
}