* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 24px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 12px;
}

/* フォームセクション */
.form-section {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.form-row input {
  flex: 1 1 120px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-row input:focus {
  border-color: #4a90d9;
}

#materialName {
  flex: 2 1 160px;
}

.form-row button {
  padding: 10px 20px;
  background: #4a90d9;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.form-row button:hover {
  background: #3a7bc8;
}

.error-msg {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #e74c3c;
  min-height: 1.2em;
}

/* 結果セクション */
.result-section {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.summary {
  font-size: 0.88rem;
  background: #eaf3ff;
  color: #2b6cb0;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
}

#tableWrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: #f0f4f8;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

tbody tr:hover {
  background: #fafbfc;
}

tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}

/* ボトルネック行 */
tbody tr.bottleneck {
  background: #fff5f5;
}

tbody tr.bottleneck td:nth-child(4) {
  color: #c0392b;
  font-weight: 700;
}

.bottleneck-badge {
  display: inline-block;
  background: #e74c3c;
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 600;
  vertical-align: middle;
}

.count-cell {
  font-size: 1.05rem;
  font-weight: 700;
  color: #2d7a2d;
}

.zero-count {
  color: #c0392b;
}

.delete-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
}

.delete-btn:hover {
  background: #fee;
  border-color: #e74c3c;
  color: #e74c3c;
}

.empty-msg {
  text-align: center;
  color: #aaa;
  font-size: 0.88rem;
  padding: 20px 0;
}

/* まとめセクション */
.batch-section {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.batch-result {
  background: #f0f9f0;
  border: 2px solid #4caf50;
  border-radius: 8px;
  padding: 16px 20px;
  text-align: center;
}

.batch-result .big-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2d7a2d;
  line-height: 1.2;
}

.batch-result .big-number.zero {
  color: #c0392b;
}

.batch-result .batch-label {
  font-size: 0.9rem;
  color: #555;
  margin-top: 4px;
}

.batch-result .batch-note {
  font-size: 0.82rem;
  color: #888;
  margin-top: 8px;
}

@media (max-width: 500px) {
  .form-row input {
    flex: 1 1 calc(50% - 8px);
  }

  #materialName {
    flex: 1 1 100%;
  }

  .form-row button {
    flex: 1 1 100%;
  }

  thead th, tbody td {
    padding: 8px 8px;
    font-size: 0.82rem;
  }

  .batch-result .big-number {
    font-size: 2rem;
  }
}
