:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657184;
  --border: #d9dee8;
  --primary: #1f6feb;
  --primary-dark: #1559c7;
  --success: #157347;
  --warning: #9a6700;
  --danger: #c7352d;
  --focus: #0b57d0;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:focus-visible,
input:focus-visible,
.drop-zone:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid rgba(11, 87, 208, 0.25);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

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

.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.secondary:hover:not(:disabled) {
  background: #eef3fb;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 40px);
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.status-pill {
  min-width: 94px;
  border-radius: 999px;
  padding: 6px 12px;
  background: #eef3fb;
  color: #244b7a;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.ok {
  background: #e6f4ea;
  color: var(--success);
}

.status-pill.ng {
  background: #fce8e6;
  color: var(--danger);
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 36px;
}

.toolbar,
.upload-panel,
.state-panel,
.alert,
.review-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar {
  padding: 12px;
  margin-bottom: 14px;
  box-shadow: none;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: #f6f8fb;
  font-weight: 700;
}

.steps span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #dfe7f3;
  color: #35506f;
  flex: 0 0 auto;
}

.steps li.active {
  background: #eaf2ff;
  color: #174ea6;
}

.steps li.active span {
  background: var(--primary);
  color: #fff;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
}

.drop-zone {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 96px;
  border: 2px dashed #b8c5d8;
  border-radius: 8px;
  background: #fbfcff;
  padding: 18px;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: #edf4ff;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.drop-copy strong {
  font-size: 17px;
}

.drop-copy span,
.notice,
.review-header p,
.state-panel p {
  color: var(--muted);
}

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

.notice {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
}

.state-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #dce5f2;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
  border-color: #f0b8b3;
  background: #fff5f4;
  color: #8d211b;
}

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

.summary-grid div {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
}

.review-panel {
  padding: 0;
  overflow: hidden;
}

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

.review-header p {
  margin: 3px 0 0;
}

.review-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  color: var(--text);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 330px);
  min-height: 320px;
}

table {
  width: 100%;
  min-width: 1600px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 6px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf3fb;
  color: #23364f;
  font-size: 13px;
  text-align: left;
}

td:first-child,
th:first-child {
  border-left: 1px solid var(--border);
}

td input,
td textarea {
  width: 100%;
  min-width: 80px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 5px 6px;
}

td textarea {
  min-height: 36px;
  resize: vertical;
}

td input:hover,
td textarea:hover,
td input:focus,
td textarea:focus {
  border-color: #9fb7dc;
}

tr.needs-review td {
  background: #fffaf0;
}

.flag {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 7px;
  background: #fff0d6;
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: #fbfcff;
}

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .upload-panel,
  .review-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .upload-actions,
  .review-actions {
    justify-content: stretch;
  }

  .upload-actions button,
  .review-actions button {
    flex: 1 1 120px;
  }

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

  .table-wrap {
    max-height: 58vh;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 14px;
  }

  h1 {
    font-size: 21px;
  }

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

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

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