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

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

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e40af;
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #bfdbfe;
}

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

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

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.15s;
  background: #f9fafb;
}

.form-group input:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.btn {
  display: inline-block;
  padding: 11px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  width: 100%;
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

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

/* 一覧セクション */
.list-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

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

.list-header h2 {
  margin-bottom: 0;
}

.total-count {
  font-size: 0.8rem;
  color: #6b7280;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 10px;
}

.empty-msg {
  text-align: center;
  color: #9ca3af;
  font-size: 0.9rem;
  padding: 24px 0;
}

/* 商品カード */
.product-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fafafa;
  position: relative;
}

.product-card:last-child {
  margin-bottom: 0;
}

.product-card.low-stock {
  border-color: #fca5a5;
  background: #fff5f5;
}

.product-card.zero-stock {
  border-color: #ef4444;
  background: #fef2f2;
}

.product-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1e293b;
  padding-right: 36px;
}

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

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 60px;
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
}

.stat-label {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #374151;
}

.stat.remaining .stat-value {
  color: #2563eb;
}

.stat.remaining.zero .stat-value {
  color: #ef4444;
}

.stat.remaining.low .stat-value {
  color: #d97706;
}

.delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.delete-btn:hover {
  color: #ef4444;
  background: #fee2e2;
}

/* 編集ボタン */
.edit-btn {
  position: absolute;
  top: 10px;
  right: 38px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.edit-btn:hover {
  color: #2563eb;
  background: #dbeafe;
}

/* 在庫更新フォーム（インライン） */
.update-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.update-form .form-group {
  flex: 1;
  min-width: 80px;
  margin-bottom: 0;
}

.update-form .form-group label {
  font-size: 0.75rem;
}

.update-form .form-group input {
  padding: 7px 10px;
  font-size: 0.9rem;
}

.update-form .btn-update {
  padding: 8px 14px;
  background: #2563eb;
  color: #fff;
  font-size: 0.85rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.update-form .btn-update:hover {
  background: #1d4ed8;
}

@media (max-width: 400px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}
