:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --panel: #ffffff;
  --text: #1e2420;
  --muted: #65716b;
  --line: #dfe3dc;
  --primary: #126b5c;
  --primary-dark: #0d4c42;
  --accent: #b74332;
  --warning: #a36a00;
  --ok: #3d6b29;
  --shadow: 0 18px 48px rgba(30, 36, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  background: linear-gradient(180deg, #f7f6f1 0%, var(--bg) 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar-actions,
.download-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.platform-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
}

.platform-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  cursor: pointer;
}

.platform-option:has(input:checked) {
  border-color: var(--primary);
  background: #eef7f4;
}

.platform-option input {
  width: 18px;
  min-height: 18px;
}

.platform-option span {
  display: grid;
  gap: 4px;
}

.platform-option strong {
  font-size: 16px;
}

.platform-option small {
  color: var(--muted);
  font-weight: 600;
}

button,
.file-button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

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

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

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

.secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

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

.file-button input {
  display: none;
}

.controls {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 12px;
  padding: 20px 32px;
  background: #fbfbf8;
  border-bottom: 1px solid var(--line);
}

label {
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(18, 107, 92, 0.14);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  border-bottom: 1px solid var(--line);
}

.summary div {
  padding: 20px 32px;
  border-right: 1px solid var(--line);
}

.summary div:last-child {
  border-right: 0;
}

.summary span {
  display: block;
  font-size: 32px;
  font-weight: 800;
}

.summary small {
  color: var(--muted);
  font-weight: 700;
}

.download-row {
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
}

#statusText {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

#statusText.error {
  color: var(--accent);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f8f5;
  color: #465049;
  font-size: 12px;
  font-weight: 800;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 42px 16px;
}

.badge {
  display: inline-flex;
  min-width: 68px;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.update,
.badge.increase {
  background: #dff0e2;
  color: var(--ok);
}

.badge.delete {
  background: #f8ded9;
  color: var(--accent);
}

.badge.decrease {
  background: #fff0cf;
  color: var(--warning);
}

.badge.keep {
  background: #ecefeb;
  color: #56615b;
}

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

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

  .platform-picker {
    grid-template-columns: 1fr;
  }

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

  .summary div:nth-child(2) {
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .topbar,
  .controls,
  .download-row {
    padding-left: 18px;
    padding-right: 18px;
  }

  .controls,
  .platform-picker,
  .summary {
    grid-template-columns: 1fr;
  }

  .summary div {
    border-right: 0;
  }

  .topbar-actions,
  .download-row,
  button,
  .file-button {
    width: 100%;
  }
}
