:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-strong: #f0f4f2;
  --line: #d9dfdc;
  --line-strong: #bcc7c1;
  --text: #1e2522;
  --muted: #63706a;
  --teal: #0f766e;
  --teal-soft: #dff3ef;
  --amber: #b87913;
  --amber-soft: #fff2d5;
  --red: #b42318;
  --red-soft: #fee4df;
  --shadow: 0 14px 34px rgba(30, 37, 34, 0.08);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  font-size: 22px;
  line-height: 1.3;
}

h2 {
  font-size: 15px;
}

.top-actions,
.table-tools,
.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button,
.mini-button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.button {
  min-height: 38px;
  padding: 0 14px;
}

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

.button.accent {
  background: var(--amber);
  border-color: var(--amber);
  color: #ffffff;
}

.button.ghost:hover,
.icon-button:hover,
.mini-button:hover {
  background: var(--surface-strong);
}

.icon-button {
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
}

.layout {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.upload-band,
.metrics,
.workspace,
.taxi-pane {
  width: 100%;
}

.upload-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) 44px minmax(180px, 0.8fr);
  align-items: stretch;
  gap: 10px;
}

.file-control {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.file-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-control input {
  width: 100%;
  color: var(--text);
  font-size: 13px;
}

.status-line {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
}

.metric,
.mapping-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 12px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  font-size: 24px;
}

.metric.warn {
  background: var(--amber-soft);
}

.metric.taxi {
  background: var(--teal-soft);
}

.metric.total {
  background: #eef3ff;
}

.mapping-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 76px;
  padding: 12px;
}

.mapping-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 35%) minmax(0, 1fr);
  gap: 14px;
  min-height: 620px;
}

.preview-pane,
.table-pane,
.taxi-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pane-head {
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.pane-head select,
.table-tools input,
.table-tools select,
.cell-input,
.cell-select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

.pane-head select,
.table-tools input,
.table-tools select {
  min-height: 34px;
  padding: 0 10px;
}

.table-tools input {
  width: min(280px, 38vw);
}

.preview-frame {
  position: relative;
  height: calc(100% - 49px);
  min-height: 560px;
  background: #eef1ef;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.preview-frame object,
.preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.table-pane {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  height: 572px;
}

table {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 7px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
}

th:nth-child(1) { width: 48px; }
th:nth-child(2) { width: 110px; }
th:nth-child(3) { width: 230px; }
th:nth-child(4) { width: 105px; }
th:nth-child(5) { width: 120px; }
th:nth-child(6) { width: 110px; }
th:nth-child(7) { width: 140px; }
th:nth-child(8) { width: 230px; }
th:nth-child(9) { width: 110px; }
th:nth-child(10) { width: 100px; }
th:nth-child(11) { width: 84px; }

tbody tr[data-state="要確認"],
tbody tr[data-state="未分類"] {
  background: #fffaf0;
}

tbody tr[data-taxi="true"] {
  box-shadow: inset 3px 0 0 var(--teal);
}

.order-cell {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cell-input,
.cell-select {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.merchant-input {
  font-weight: 700;
}

.amount-input {
  text-align: right;
}

.tax-input {
  font-size: 12px;
}

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

.mini-button {
  width: 34px;
  height: 32px;
  padding: 0;
  font-size: 12px;
}

.mini-button.danger {
  color: var(--red);
}

.state-select[value="要確認"],
.state-select[value="未分類"] {
  border-color: var(--amber);
}

.taxi-pane {
  min-height: 160px;
}

.taxi-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 12px;
}

.taxi-item {
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--teal-soft);
}

.taxi-item strong {
  font-size: 14px;
}

.taxi-item span {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  color: var(--muted);
  padding: 16px;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .upload-band,
  .metrics,
  .workspace {
    grid-template-columns: 1fr;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .button {
    flex: 1 1 140px;
  }

  .preview-frame {
    min-height: 420px;
  }
}

@media (max-width: 700px) {
  .topbar {
    padding: 14px;
  }

  h1 {
    font-size: 18px;
  }

  .layout {
    padding: 10px;
  }

  .table-tools {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

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

  .table-head h2 {
    white-space: nowrap;
  }

  .table-tools input,
  .table-tools select {
    width: 100%;
  }
}
