:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #64707d;
  --line: #d9dee5;
  --soft: #eef2f6;
  --primary: #0f6b62;
  --primary-strong: #0a514b;
  --ok: #126a3a;
  --warn: #8a5a00;
  --danger: #a43b34;
  --radius: 8px;
  font-family: "Meiryo", "Yu Gothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 14px;
}

.status-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  min-width: 92px;
  padding: 8px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.section-head.compact {
  margin-top: 18px;
  margin-bottom: 10px;
}

.upload-grid,
.mapping-grid,
.preview-grid,
.stats-grid {
  display: grid;
  gap: 12px;
}

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

.drop-zone {
  display: grid;
  gap: 8px;
  min-height: 132px;
  align-content: center;
  border: 1px dashed #aab4c0;
  border-radius: var(--radius);
  padding: 16px;
  background: #fbfcfd;
  cursor: pointer;
}

.drop-zone input {
  width: 100%;
  min-width: 0;
}

.label,
.mapping-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.file-name {
  overflow-wrap: anywhere;
  font-size: 13px;
}

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

.mapping-grid label {
  display: grid;
  gap: 6px;
}

.mapping-grid input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  text-transform: uppercase;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

button,
.download {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 14px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

.primary:hover,
.download:hover {
  background: var(--primary-strong);
}

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

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

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

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

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.stat.ok strong {
  color: var(--ok);
}

.stat.warn strong {
  color: var(--warn);
}

.stat.danger strong {
  color: var(--danger);
}

.alerts {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.alert {
  border: 1px solid #e3c878;
  border-radius: 6px;
  background: #fff8e3;
  color: #5c4300;
  padding: 10px 12px;
  font-size: 13px;
}

.alert.error {
  border-color: #e7a09b;
  background: #fff0ee;
  color: #7c1d18;
}

.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.hidden {
  display: none;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  background: #f0f3f6;
  color: #39424d;
  font-weight: 700;
}

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

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

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 20px, 760px);
    padding-top: 16px;
  }

  .topbar,
  .tool-grid,
  .upload-grid,
  .mapping-grid,
  .preview-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 21px;
  }

  .actions {
    display: grid;
  }

  button,
  .download {
    width: 100%;
  }
}
